Bar graph coloring and shading

I want to be able to shade/color a bar graph orange. I want the darkest or brightest orange to be at the far right, and have it get lighter to an almost whitish orange at the left of the graph. heres what ive been trying so far: the middle option wouldnt work cause I couldnt get orange any help since it's not available.
x=(1:13)
y=[177;47;40;21;21;13;12;14;10;5;2;4;3]
bar(x,y)
% bar([177,0,0,0,0,0,0,0,0,0,0,0,0],'r');
% hold on
% bar([0,47],'b');
% bar([0,0,40],'g')
% bar([0,0,0,21],'g')
% bar([0,0,0,0,21],'g')
% bar([0,0,0,0,0,13],'g')
% bar([0,0,0,0,0,0,12],'g')
% bar([0,0,0,0,0,0,0,14],'g')
% bar([0,0,0,0,0,0,0,0,10],'g')
% bar([0,0,0,0,0,0,0,0,0,5],'g')
% bar([0,0,0,0,0,0,0,0,0,0,2],'g')
% bar([0,0,0,0,0,0,0,0,0,0,0,4],'g')
% bar([0,0,0,0,0,0,0,0,0,0,0,0,3],'g')
set(gca,'XTickLabel',{'0-4.5','5-9.5','10-14.5','15-19.5','20-24.5','25-29.5','30-34.5','35-39.5','40-44.5','45-49.5','50-54.5','55-59.5','>60'})

답변 (1개)

Sean de Wolski
Sean de Wolski 2013년 3월 20일

0 개 추천

댓글 수: 3

Dimitri
Dimitri 2013년 3월 20일
Thank you for those, but I still dont know how to "shade" my bar graphs. Do i have to manually input all my colors for orange? or is there a way to make it so theres just a gradient that goes across all bars? So the first bar will be light, and the last bar will be dark. I also want them to be orange, not sure if that makes a difference.
Sean de Wolski
Sean de Wolski 2013년 3월 20일
Sorry, missed the shading part. You will have to set the shading to interp in there somewhere. I'll see if I can find it. If not, this would be easy with patch objects.
Dimitri
Dimitri 2013년 3월 20일
편집: Dimitri 2013년 3월 20일
I'm really not that proficient in Matlab, so sorry for not really understanding. But, i'm confused as to what these two links are giving me.
Can I still use what I had? The following:
x=(1:13)
y=[177;47;40;21;21;13;12;14;10;5;2;4;3]
bar(x,y)
set(gca,'XTickLabel',{'0-4.5','5-9.5','10-14.5','15-19.5','20-24.5','25-29.5','30-34.5','35-39.5','40-44.5','45-49.5','50-54.5','55-59.5','>60'})
And how do I use the color orange? And make it so it's shaded? I have seen the shade command, and tried using it with what I had, but couldnt get it to work. I believe i used
shade interp
right after
bar(x,y)

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

카테고리

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

질문:

2013년 3월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by