2014-10-11 73 views
4

如何查找使用Matlab R2014b彩條需要多少空間?我需要知道總的大小,包括所有的標籤,但如果我不顏色條的大小,包括Matlab中的標籤R2014b

c = colorbar; 
get(c,'TightInset'); 

我使用matlab.graphics.illustration.ColorBar得到錯誤信息

錯誤/獲取
沒有TightInset ColorBar類中的屬性。

OuterPosition也一樣。顯然,R2014b中的ColorBar類不再支持這些屬性。

回答

0

嘗試:

original = get(c, 'Position') 
set(c, 'Position', [original(1) original(2)*0.5, original(3), original(4)*0.5]) 

手柄C包含一個 '位置' 屬性,同許多圖形手柄。查閱文檔以更全面地瞭解它。爲了驗證這一轉變彩條的標題和標籤的位置太,執行以下命令:

set(get(c, 'YLabel'), 'String', {'a', 'b', 'c'})  % Arbitrary Labels 
set(get(c, 'Title'), 'String', {'Colorbar Title'}); % Arbitrary Title 
set(c, 'Position', [original])      % Resize back to original and observe! 
+0

據我瞭解Position屬性不包括刻度標記,標籤,標題和軸標籤(見[HTTP ://www.mathworks.ch/ch/help/matlab/creating_plots/automatic-axes-resize.html](http://www.mathworks.ch/ch/help/matlab/creating_plots/automatic-axes-resize。 HTML))。 – user1919235 2014-10-11 10:29:56

+0

嘗試我編輯的回覆,應該做你想做的。 – danny 2014-10-11 10:37:21

+0

我很抱歉,但我不明白你的答案。我想知道的是彩條佔用的空間量,包括刻度線,標籤,標題和軸標籤。所以我期待一個形式width = ...和height =的答案... – user1919235 2014-10-11 10:47:49