2016-09-18 62 views
0

我想添加對象到我已定義x個極限但跨越整個y範圍的matlab圖中。示例是由兩個x值分隔的垂直線或陰影區域。我知道的選項使用當前的情節限制這樣的:如何免除Matlab繪圖極限計算中的對象

plot(1:10) 
yl = ylim(); 
% Use y limits of current plot as y values 
patch([ 3 3 5 5 ],[ yl(1) yl(2) yl(2) yl(1) ], 'red'); 

enter image description here

但是我希望我的用戶能夠增加繪Y極限之後(例如,同步多個地塊的限制)並希望他們繼續從Matlab的繪圖限制自動設置中獲益。

這將是可存檔的,如果我的計算過程中使用下面的代碼,以我的對象的y座標設置爲最大和最小的整數,分別爲(intmax()並在Matlab intmin()),並告訴MATLAB不考慮對象繪圖限制。

plot(1:10) 
% Make graphical object which spans the whole possibly y range 
p = patch([ 3 3 5 5 ],[ intmin intmax intmax intmin ], 'red'); 
% Does something like the following function exist? 
exemptFromPlotLimitsCalculation(p) 

這是可能的Matlab?

回答

1

你可以(通過使用realmax例如)繪製patch(或fill)真大,從通過設置重新調整排除物業YLimInclude關閉

patch([3 3 5 5], realmax*[ -1 1 1 -1], 'red', 'YLimInclude', 'off'); 
+0

爲什麼我找不到此選項?謝謝! – akraf

1

看看this

在postActionCallback你可以調整你的補丁

+0

謝謝。在這種情況下,@ nilZ0r的解決方案更容易,但是在調整子圖之間的距離時,我仍然可以使用您的建議! – akraf