how to make histogram?

2 visualizaciones (últimos 30 días)
eri
eri el 13 de En. de 2013
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]

Respuestas (2)

Wayne King
Wayne King el 13 de En. de 2013
Editada: Wayne King el 13 de En. de 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.

Walter Roberson
Walter Roberson el 13 de En. de 2013

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by