Matlab 为什么有时带bar或hist的酒吧没有边框?

Matlab 为什么有时带bar或hist的酒吧没有边框?,matlab,graph,plot,histogram,Matlab,Graph,Plot,Histogram,我注意到,有时,当我使用函数bar()或hist()绘制条形图时,绘制的条形图没有边框。它们看起来不太好看,我更喜欢它们之间的边界或一点空间。 图中显示了我现在得到的,绘制了三个不同的数据集。第三个图形被放大,以显示条之间缺少空间。 我明白了,这与bar函数中的“histc”参数有关。如果没有histc参数,条之间有一些空间,但是条将以边值为中心,而我希望边值是每个条的边 这是我使用的代码(相关部分): [...] if edges==0 %these following

我注意到,有时,当我使用函数bar()或hist()绘制条形图时,绘制的条形图没有边框。它们看起来不太好看,我更喜欢它们之间的边界或一点空间。 图中显示了我现在得到的,绘制了三个不同的数据集。第三个图形被放大,以显示条之间缺少空间。

我明白了,这与bar函数中的“histc”参数有关。如果没有histc参数,条之间有一些空间,但是条将以边值为中心,而我希望边值是每个条的边

这是我使用的代码(相关部分):

 [...]
 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');
    [...]

我想如果你改变条形图的颜色,你会发现实际上有一个边框,它显示得不太好。您还可以更改条的宽度,使其更清晰

% 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');

我认为,如果你改变条形图的颜色,你会发现实际上有一个边框,它显示得不太好。您还可以更改条的宽度,使其更清晰

% 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');

对象的
EdgeColor
LineWidth
属性控制条形图轮廓。尝试使用代码并使用红色、绿色、蓝色和宽度值来获得更好的结果

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

对象的
EdgeColor
LineWidth
属性控制条形图的轮廓。尝试使用代码并使用红色、绿色、蓝色和宽度值来获得更好的结果

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