我在MATLAB中编写了一个绘制直方图的代码.我需要将其中一个箱子的颜色与其他箱子颜色不同(让我们说是红色).有谁知道怎么做?例如,给定:
A = randn(1,100);
hist(A);
Run Code Online (Sandbox Code Playgroud)
我如何制作0.7属于红色的箱子?
我试图呈现两个直方图,我希望它们中的每一个都有不同的颜色.让我们说一个红色和一个蓝色.到目前为止,我把改变了两者的颜色,但只改为相同的颜色.
这是代码
close all
b=-10:1:10;
x=randn(10^5,1);
x=(x+5)*3;
y=randn(1,10^5);
y=(y+2)*3;
hist(x,100)
hold on
hist(y,100);
h = findobj(gca,'Type','patch');
set(h,'FaceColor','r','EdgeColor','w')
%the last two lines changes the color of both hists.
Run Code Online (Sandbox Code Playgroud)