Bar graph in RGB Colors

16 views (last 30 days)
Ferdinand
Ferdinand on 9 Oct 2012
Hi,
I would like to plot a bar graph in rgb-colors ('Color',[R G B]). I tried to do it the normal way handle=bar(y,x,'Color',[R G B]) and by set(handle,'Color',[R G B]) but it didn't work out.
Could anyone help me on this one? =)
Greetings from Germany!
Ferdinand

Answers (2)

Walter Roberson
Walter Roberson on 9 Oct 2012
bar() plots in modern MATLAB create a barseries object. The barseries object has a series of Children, each of which is a patch object, with the color of the patch object being controlled by its CData property. Each patch object represents one original column in y (in the multi-column case).
However, user testing has found that if there are 1000 or more columns that instead of individual patches, a single patch object is created with all of the data.

Image Analyst
Image Analyst on 9 Oct 2012
Try 'FaceColor' instead of 'Color':
x = 30:40;
y = rand(length(x),1);
bar(x,y, 'FaceColor', [.42 .37 .73]); % Values in the 0-1 range for FaceColor
grid on;

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!