フィルターのクリア

how to make histogram?

3 ビュー (過去 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 Center および File ExchangeHistograms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by