Problem with the legend for the multiple axes.

1 回表示 (過去 30 日間)
Aftab Ahmed Khan
Aftab Ahmed Khan 2015 年 2 月 27 日
編集済み: Aftab Ahmed Khan 2015 年 2 月 27 日
Hi everyone, I am plotting two graph using multiple axes option, the problem i am having now is with the legend. It is displaying only the first graph but not the for the second graph. I am doing it in this way,
hold on;
line(channels1,cabschusage_percent,'Color','k')
ax1 = gca; % current axes
ax1_pos=get(ax1,'Position');
ax2 = axes('Position',ax1_pos,'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none');
line(channels2,hbschusage_percent,'Parent',ax2,'Color','r');
set(ax2,'XColor','r');
set(ax2,'YColor','r');
legend('CABS Channel Usage', 'HBS Channel Usage');
grid on;
axis tight;
hold off;

採用された回答

Brendan Hamm
Brendan Hamm 2015 年 2 月 27 日
The axes legend is a child of the axes and therefore it does not know about the line on the other axes. One thing you consider is just using the plotyy(...) function.
  2 件のコメント
Aftab Ahmed Khan
Aftab Ahmed Khan 2015 年 2 月 27 日
Hi, thank you for the reply. If i use plotyy function it put my second x-axis on top of the first x-axis. I want one of them to be on the top as they are different from each other.
Aftab Ahmed Khan
Aftab Ahmed Khan 2015 年 2 月 27 日
編集済み: Aftab Ahmed Khan 2015 年 2 月 27 日
Hi, Anyways i manage to do it like this by putting different xlabels and ylabels. Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by