您可以創建兩個次要情節和,但他們在一起
% plotting
figure;
p1 = subplot(2,1,1);
idx = x>=0; plot(vector(idx), x(idx));
p2 = subplot(2,1,2);
idx = x<=0; plot(vector(idx), x(idx));
% Make x-axis limits the same (must use datenum)
lims = datenum([min(vector), max(vector)]);
xlim(p1, lims); xlim(p2, lims);
% Make the plots meet in the middle
h = 0.45; w = 0.9; % height and width
set(p1, 'position', [(1-w)/2, 0.5, w, h])
set(p2, 'position', [(1-w)/2, 0.5-h, w, h])
% Ensure the y axes meet at 0
ylim(p1, [0, max(x)]); ylim(p2, [min(x), 0]);
兩個個別地塊但是可以做你喜歡。所以如果你用相關的方法繪製它們,你會得到一個指數y軸和一個log y軸。
不是以上plot(...)
行的,你可以使用
% log y plot
semilogy(datenum(vector(idx)), x(idx))
注意,這個輸出工作完全符合預期,但你正在試圖做實際的情節聽起來很混亂。在大多數情況下,如果這些軸真的想與衆不同,那麼將其作爲兩個獨立的情節呈現出來可能會更好。在這種情況下,請使用上面的代碼而不使用position
行!
之前的情節類型亂搞,這是輸出的樣子,上面和在0線下方的Y軸是完全獨立的,因爲這實際上是2個地塊:
![plot](https://i.stack.imgur.com/w8ZCn.png)
謝謝!它工作正常,但我想我同意它看起來很混亂;)所以我會用2個地塊,而不是正常的規模,一個與日誌規模。現在我知道如何用日期做半日誌,我唯一的問題是:「不顯示負值」。你有什麼建議? – LenaH