Re: creating bars (bar function): each bar with a different color?
- From: Peter Boettcher <boettcher@xxxxxxxxxx>
- Date: Tue, 29 Nov 2005 17:25:25 -0500
"stephane bourgeois" <stephane.bourgeois@xxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:
> Hello,
>
> let's say I have data representing the counts of three differents
> items:
>
> u=[4 8 1];
>
> when I do bar(u) I get a bar figure of the counts, which is fine.
>
> But what I really want is assigning a different color to each bar.
> The figure edition tool changes the colors of all bars, and does not
> seem to allow a bar-by-bar selection.
>
> Anyone has an idea on how to do it?
Play with the properties of handle graphics. The details will
probably vary by version. With my version, for instance:
h=bar(u);
s=get(h, 'Children');
set(s, 'CData', [1 2 9]);
The colors will reference the current colormap
Or, for direct RGB specification, use Nx3 RGB triplets:
set(s, 'FaceVertexCData', [r1 g1 b1; r2 g2 b2; r3 g3 b3]);
--
Peter Boettcher <boettcher@xxxxxxxxxx>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/
.
- References:
- creating bars (bar function): each bar with a different color?
- From: stephane bourgeois
- creating bars (bar function): each bar with a different color?
- Prev by Date: Re: bar ??
- Next by Date: Re: Returning an array with doubles and chars from mex
- Previous by thread: Re: creating bars (bar function): each bar with a
- Next by thread: Whats the best way to pass a matlab struct to java code?
- Index(es):
Relevant Pages
|