how to make histogram?

2 次查看(过去 30 天)
eri
eri 2013-1-13
i have a data of closing price for various stock, i want to make a histogram from it, and i want the histogram to be drawn as one. ex data: stock-A=[5 7 4 9 4 5 7 4] stock-B=[100 130 200 160 140 180 200 210]

回答(2 个)

Wayne King
Wayne King 2013-1-13
编辑:Wayne King 2013-1-13
You simply hold on the plot and put both histograms on. Then you will want to modify the 'FaceColor' and possibly 'EdgeColor' properties of the one of the objects so you can tell the two histograms apart.
You may also want to set the 'FaceAlpha' to make one histogram more transparent depending on how the two histograms overlap.
StockA = randn(1000,1)+7;
StockB = 0.75*randn(1000,1)+8;
hist(StockA); hold on;
hist(StockB);
h = findobj('-property','FaceColor');
set(h(1),'FaceColor',[1 0 0],'EdgeColor',[1 0 0],'facealpha',0.5);
If you enter h at the command line, you'll see that h is two numbers, one for each histogram in the plot. Use h(1) to modify the properties of one object and h(2) to modify the properties of the other.

Walter Roberson
Walter Roberson 2013-1-13

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by