Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Color Palette

From   [email protected] (Vince Wiggins, StataCorp)
To   [email protected]
Subject   Re: st: Color Palette
Date   Thu, 20 Feb 2003 11:22:18 -0600

Friedrich Huebler <[email protected]> asks about getting a palette of
all the named colors available in Stata graphics,

> The command -palette color- allows the comparison of two colors. It
> would be useful to have a command that shows all available colors. I
> envision a program that takes the colors returned by -graph query
> colorstyle- and turns them into a checkerboard or similar pattern. I
> don't know how to do this but perhaps someone could volunteer to
> write such a program.

I wanted to point out a few things related to Friedrich's request.  (The
program sounds interesting, but I am not volunteering.)

First, and this may be obvious, is that the colors in graphics are not limited
to the named colors -- that is to say limited to those colors returned by
-graph query colorstyle-.  Anywhere a named color is allowed, we can also use
an RGB triplet.  For example the two commands,

      . scatter mpg weight , mcolor(blue)


      . scatter mpg weight , mcolor("0 0 255")

produce graphs that look the same -- both have blue symbols.  What's more, we
could have used any RGB triplet in place of "0 0 255" and in that way
requested any of the 16,777,216 colors in the RGB palette.

Second, for a peek inside one part of graphics programming, you can create
your own named colors.  If Friedrich decides that none of the official named
reddish colors are acceptable, he can define a new named color by simply
creating a .style file and placing it anywhere along his -adopath-.  To define
a new named color a .style file needs only a single -set- statement with an
RGB triplet.  For example, Friedrich could create the file,

--------------------------- BEGIN --- --- CUT HERE -------
set rgb "180 30 30"
--------------------------- END   --- --- CUT HERE -------

and place it in his personal ado director (type -sysdir- to find this
directory).  He could even place it in the current working directory, but then
the color -fredred- would only be available when working in that directory.
Friedrich can now use that named color anywhere an official named color could
be used, for example

      . scatter mpg weight , mcolor(fredred)

The structure of the filename is important.  The name has two parts, separated
by a "-" and must also have a ".style" extension, formally


<style_type> can be any of Stata's named styles, e.g. "color" or "margin", and
<new_style_name> should be a legal Stata name that is unique for the

Note that the internal stylename is what must be used for <style_type> and
that name sometimes differs from what is shown by -graph query-.  For example,
the internal name of the -textsizestyle- is -gsize-.  So, if we want to define
a new textsize, say -ebig-, the filename would be

-- Vince
   [email protected]

P.S. If you create a new .style file during a Stata session, you must type
     -discard- or -clear- to make the file accessible.  Otherwise, the new
     named style will not be available until a new Stata session is started.

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index