Colour each bar in histogram and add a colorbar

Hi
I have a histogram with a number of points so its too many to label on the x-axis.
How do I colour each bar on the histogram a different colour then add a 'colorbar' where I can label the data each coloured bar refers to.
Many thanks

답변 (2개)

Grzegorz Knor
Grzegorz Knor 2011년 9월 1일

0 개 추천

The ability to change the color in each bar of a plot is not built into MATLAB:
You can solve it use my function from FEX:
Y = 1+rand(10,1);
clrs = repmat(1:10,6,1);
StemBar(1:length(Y),0*Y,Y,clrs(:)')
set(gca,'XDir','reverse')
view([180 0])
colorbar
You can modify source code for 2D case.
Grzegorz

댓글 수: 1

http://www.mathworks.com/support/solutions/en/data/1-1T6UHS/

댓글을 달려면 로그인하십시오.

Greg
Greg 2011년 9월 1일

0 개 추천

In that case I would prefer to label only those bars above a certain value rather than labelling equally spaced out bars that Matlab seems to do when there is not enough space to label all bars.
Can this be done?
e.g label if bar value is > x Thanks

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품

질문:

2011년 9월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by