how to make histogram?
2 views (last 30 days)
Show older comments
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]
0 Comments
Answers (2)
Wayne King
on 13 Jan 2013
Edited: Wayne King
on 13 Jan 2013
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.
0 Comments
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!