2016-07-26 58 views
1

我有大量的子圖我必須使用Matlab加載並放在一起。我想添加個性化的Ticks,但我的方法似乎不起作用。我的主機是以下內容:更改XTick在子圖中不起作用

x = 1:1:1000; 
r = rand(1000,1); 
my1 = subplot(2,3,1); 
my1 = bar(x,sort(r)); 
title ('This works') 
xlabel ('This works too') 
xlim ([0 1000]) 
my = get(gca); 
my.XTick = [1 200 499] 

而這最後一點不起作用。爲什麼?我該如何解決它?

回答

2

get(gca)返回當前軸的所有圖形屬性的struct,而不是軸處理自身。對此struct屬性所做的任何更改都不會反映在您的實際axes中。你需要使用直接set

set(gca, 'XTick', [1 200 499]) 

修改axes的屬性,或者,如果你是在2014B

% Don't use get(gca) to get the handle 
ax = gca; 

% Set the XTick property 
ax.XTick = [1 200 499]; 
+0

明白了。非常感謝,我仍然不習慣Matlab圖形環境 – Patapunfate