how to make histogram?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (2개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!