Bar Plot with 2 Y axes and same X- axis
Show older comments
Hi , I have 2 vectors called R_per and A_per with some distinct values. They share a common base called the per.
I need to plot both R_per and A_per w.r.t Per in a Bar plot. The bar must be grouped as shown in this picture:
http://it.mathworks.com/help/releases/R2014b/examples/graphics/BarGraphof2DArrayExample_01.png They must also have a common X axis scaling.
I tried using plotyy and did the wrote the following code:
[hyy,hl,ho]=plotyy(per , A_per, per, R_per,'bar','bar');
xt = get(gca, 'XTick');
set(gca, 'XTick', xt, 'XTickLabel', {'200' '300' '400' '500' '700'})
set(ho,'facecolor','r','barwidth',0.2)
set(hl,'facecolor','g','barwidth',0.3)
What i get is a overlapped bar plot with uneven spacing and unclean Y axes.

Can someone help ?
Thanks in advance.
Regards, Vittal
Accepted Answer
More Answers (0)
Categories
Find more on Two y-axis 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!