How to add a second Y axis to a bar chart?

21 views (last 30 days)
Hi all , I am trying to make a bar chart with readings of particulate matter. Since one of my observations is an outlier my graph does not look right. Is there anyway I could add a second Y axis to my code?
Thanks in advance for your help
%% pdr bar chart
x1=[ 1 2 3 4 5 6 7 8 9 ];
b1=[12.74 33.47; 71.06 29.25; 43.69 17.20;166.75 111.0; 796.17 3266; 519.0 55.27; 7.18 0; 123.25 0; 25.00 0];%% PM 2.5 readings
xtips1 = y1(1).XEndPoints;
ytips1 = y1(1).YEndPoints;
labels1 = string(y1(1).YData);
xtips2= y1(2).XEndPoints;
ytips2 = y1(2).YEndPoints;
labels2 = string(y1(2).YData);

Answers (1)

Sara Boznik
Sara Boznik on 14 Aug 2020
I recomend you that you use plotyy.
Below you have an example.
[ax,h1,h2] = plotyy(f,[a',b',d',U'],f,I);
set(ax(1),'YLim',[-2 2])
set(ax(2),'YLim',[-15 15])
I hope that this will help you somehow. Good luck.
Sara Boznik
Sara Boznik on 14 Aug 2020
Sorry, I don't know, I am not so experienced here and I am trying to help as much as I can. And ofc it is very useful to learn something new with this MATLAB Answers.
Wish you best of luck.

Sign in to comment.


Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by