【发布时间】:2015-12-01 02:32:55
【问题描述】:
我知道plotyy,但在我看来,它不像输入subplot(2,3,1) 那样直观,从那时起,在该特定子图的环境中工作...
假设我有以下数据:
a=rand(20,1);
a_cumul=cumsum(a);
我想在主要(左侧)y 轴上绘制 plot 或 a_cumul,在次要(右侧)y 轴上绘制 a 条形图。
我很清楚我可以做到:
plotyy(1:length(a_cumul),a_cumul,1:length(a),a,'plot','bar')
但这很麻烦,如果我只想绘制到辅助 y 轴而不绘制到主 y 轴怎么办?简而言之,我正在寻找这样的解决方案是否存在:
figure;
switchToPrimaryYAxis; % What to do here??
plot(a_cumul);
% Do some formatting here if needed...
switchToSecondaryYAxis; % What to do here??
bar(a);
非常感谢您的帮助!
【问题讨论】:
标签: matlab plot bar-chart axis axes