2015-02-05 56 views
0
把標籤上的每個數據點在幹情節

,所以這是我的X和Y數據:如何使用MATLAB

x = [29.745, 61.77, 42.57, 70.049, 108.51, 93.1, 135.47, 52.79, 77.91, 116.7, 100.71, 146.37, 125.53] 
y = [6, 6, 12, 24, 24, 12, 24, 8, 24, 24, 24, 48, 8] 

stem(x,y); 

,所以我要標註在我乾的情節每個數據點,這個我想輸出I想要:enter image description here

我編輯它使用油漆,可以matlab做這個垂直標籤?只是圖像的樣子?請幫忙。

回答

1

是的,它可以!你只需要提供值爲90的文本註釋的rotation屬性,它工作正常。

例子:

clear 
clc 


x = [29.745, 61.77, 42.57, 70.049, 108.51, 93.1, 135.47, 52.79, 77.91, 116.7, 100.71, 146.37, 125.53] 
y = [6, 6, 12, 24, 24, 12, 24, 8, 24, 24, 24, 48, 8] 

hStem = stem(x,y); 

%// Create labels. 
Labels = {'none'; 'true';'false';'mean';'none';'';'true';'hints';'high';'low';'peas';'far';'mid'} 

%// Get position of each stem 'bar'. Sorry I don't know how to name them. 
X_data = get(hStem, 'XData'); 
Y_data = get(hStem, 'YData'); 

%// Assign labels. 
for labelID = 1 : numel(X_data) 
    text(X_data(labelID), Y_data(labelID) + 3, Labels{labelID}, 'HorizontalAlignment', 'center','rotation',90); 
end 

其中給出以下幾點:

enter image description here

的最後一個標籤是有點高,所以你可能要重新調整軸,但你的想法。

+0

哦,你的我的英雄非常感謝! :)) – matlabnewbie 2015-02-05 16:45:02

+0

哈哈哦謝謝! :) – 2015-02-05 16:59:09