Problem with the legend for the multiple axes.
3 次查看(过去 30 天)
显示 更早的评论
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;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147345/image.png)
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!