2013-08-29 199 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);