以下代碼顯示了我的問題。如果蜱不在兩側的相同位置(這是正常情況下...),則plotyy完全失敗(matlabs只能在一邊繪製每個繪圖的座標軸
我需要一個有兩個y軸的繪圖,但只在一側繪製刻度。我被建議使用addaxis,但我不明白這對我有什麼幫助,因爲我不想分開的軸。
clf;
clc;
xaxis = 0:0.1:25;
ydata1 = linspace(12.1712,12.7679, length(xaxis));
ydata2 = linspace(0.3597,-28.7745, length(xaxis));
[AX,H1,H2] = plotyy(xaxis, ydata1, xaxis, ydata2);
% axis limits - x axis (min to max)
xlimits(1) = min(xaxis); xlimits(2) = max(xaxis);
set(AX, 'XLim', xlimits);
set(AX(2),'XTick',[]);
% y1 axis limits
ylimits(1) = min(ydata1); ylimits(2) = max(ydata1);
ylimits(2) = ylimits(2) + (ylimits(2)-ylimits(1))*0.05;
set(AX(1), 'YLim', ylimits);
% y2 axis limits
ylimits(1) = min(ydata2); ylimits(2) = max(ydata2);
ylimits(2) = ylimits(2) + (ylimits(2)-ylimits(1))*0.05;
set(AX(2), 'YLim', ylimits);
% y1 ticks
set(AX(1),'YTick',[12.0:0.1:12.8]);
% y2 ticks
set(AX(2),'YTick',[-25:5:0]);
print(gcf, ['-r' num2str(400)], ['test' '.png' ], ['-d' 'png']);
'set(AX(2),'XAxisLocation','top','XTickLabel',[]);' – craigim 2014-03-14 15:57:12