Discussion:
Specifying colors in gscatter using rgb codes
(too old to reply)
Gaurav
2011-07-01 04:18:47 UTC
Permalink
Hi all,

I am trying to use the gscatter function to group the (x,y) points
being plotted in a plot. However, I don't like the default colors
being assigned to these groups. Is there any way to specify the color
of the markers to each group using rgb codes? It appears that there
may be some way to do this using colormaps, but changing the colormap
of the image to winter or summer (my preferred colormaps), but doing
this using the property editor gui did not yield any useful results.
Maybe I'm on the wrong track using colormaps?

I'd deeply appreciate if somebody could give a (possibly detailed)
reply to this query. I am a newbie and and am under some time pressure
to do this, so please help.

Thanks,

Gaurav
Steven_Lord
2011-07-01 13:41:33 UTC
Permalink
Post by Gaurav
Hi all,
I am trying to use the gscatter function to group the (x,y) points
being plotted in a plot. However, I don't like the default colors
being assigned to these groups. Is there any way to specify the color
of the markers to each group using rgb codes?
With RGB codes? No.
With letters representing a color? Yes. The accepted letters are listed in
the documentation for GSCATTER as well as in the Color Specification
documentation:

http://www.mathworks.com/help/toolbox/stats/gscatter.html
http://www.mathworks.com/help/techdoc/ref/colorspec.html

Use these as the clr input listed in the documentation. Note that only the
'short names' appear to be recognized by GSCATTER.
Post by Gaurav
It appears that there
may be some way to do this using colormaps, but changing the colormap
of the image to winter or summer (my preferred colormaps), but doing
this using the property editor gui did not yield any useful results.
Maybe I'm on the wrong track using colormaps?
It does not appear, from the documentation, that GSCATTER uses the colormap
at all.

If you must use RGB codes, you could retrieve the handles from GSCATTER (the
output argument), determine to which group each line corresponds, and use
SET to change that line's Color property. But this is a bit more of an
advanced maneuver.
--
Steve Lord
***@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
Doug Schwarz
2011-07-01 16:41:21 UTC
Permalink
Post by Steven_Lord
Post by Gaurav
Hi all,
I am trying to use the gscatter function to group the (x,y) points
being plotted in a plot. However, I don't like the default colors
being assigned to these groups. Is there any way to specify the color
of the markers to each group using rgb codes?
With RGB codes? No.
Undocumented, to be sure, but you can pass in an Nx3 matrix of colors
(RGB, 1 color per row) as the 4th argument.

The documentation only mentions the letter codes, but even that is wrong
since it specifies that the color order is 'bgrcmyk'. but really the
colors are taken from the hsv colormap. If k is the number of groups,
the colors are the rows of hsv(k).

Indeed, if you specify the letters, gscatter will use the colors you
specify.
--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
Loading...