2013-08-29 196 views
1

我注意到有時,當我使用函數bar()或hist()繪製條形圖時,繪製的條形圖沒有邊框。他們看起來不太高興,我更喜歡他們之間的邊界或一點空間。 該圖顯示了我現在得到的結果,繪製了三個不同的數據集。第三張圖放大以顯示條之間的空間不足。 enter image description here爲什麼有時酒吧或酒吧的酒吧沒有邊界?

我到那裏,這與條形函數中'histc'參數有關。如果沒有histc參數,小節之間會有一些空格,但是小節將以邊的值爲中心,而我希望邊的值是每個小節的EDGES。

這是(相關部分),我使用的代碼:

[...] 
if edges==0 
     %these following lines are used to take the min and max of the three dataset 
     maxx=max(cellfun(@max, reshape(data,1,size(data,1)*size(data,2)))); 
     minn=min(cellfun(@min, reshape(data,1,size(data,1)*size(data,2)))); 
     edges=minn:binW:maxx+binW; 
    end 
    [...] 
    y{k}=histc(data{r,c}, edges); 
    bar(edges,y{k} , 'histc'); 
    [...] 

回答

1

我認爲,如果你改變你的酒吧地塊的顏色,你會看到有實際上是一個邊境它只是不表現得非常好。你也可以改變條的寬度,使它們更加清晰。

% something to plot 
data = 100*rand(1000,1); 
edges = 1:100; 

hData = histc(data,edges); 

figure 
subplot(2,1,1) 
h1 = bar(edges,hData,'histc'); 
% change colors 
set(h1,'FaceColor','m') 
set(h1,'EdgeColor','b') 

% Change width 
subplot(2,1,2) 
h1 = bar(edges,hData,0.4,'histc'); 

enter image description here

0

Barseries對象控制桿輪廓的EdgeColorLineWidth性質。嘗試使用代碼並使用紅色,綠色,藍色和寬度值來獲得更好的結果。

red = 1; 
    green = 1; 
    blue = 1; 
    width = 3; 
    h = bar(edges,y{k} , 'histc'); 
    set(h,'EdgeColor',[red green blue],'LineWidth',width);