Bar plot with two Y-axes
255 ビュー (過去 30 日間)
I need to plot data in a bar plot with two Y axis. Morevover the bar must be grouped, like in the following picture:
I have tried the following code but the result is far to be fine.
[AX,H1,H2] =plotyy([1:10],a, [1:10]-0.5,b, 'bar', 'bar');
the problems are:
- Item one: There are two overlapped x-axis, but I need only one.
- Item two: the bars are not each next to the other,
Orion 2014 年 11 月 29 日
a=[rand(10,1)*100 zeros(10,1) ];
b=[zeros(10,1) rand(10,1)*5 ];
[AX,H1,H2] =plotyy([1:10],a, [1:10],b, 'bar', 'bar');
set(H1,'FaceColor','r') % a
set(H2,'FaceColor','b') % b
その他の回答 (1 件)
dpb 2014 年 11 月 30 日
編集済み: dpb 2014 年 11 月 30 日
...I get only two red entries in the legend. How may I solve it?
Use the handles, Luke... :) You've faked which bars are to be seen but have duplicates so have to use the handles associated with the two bars only of the ones that are wanted to be observed. Hn are each 2-vectors; use the first of each --