Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Exploring graph colors / colours

From (Vince Wiggins, StataCorp)
Subject   Re: st: Exploring graph colors / colours
Date   Tue, 15 Feb 2011 00:31:27 -0600

Allan Reese <> divines that, although
undocumented, anyone can create new named colors in Stata's graphics by
adding simple .style files to their PERSONAL or SITE directories (type
-adopath- to find these),

> [...] This suggests a mechanism for adding your own named
> color (eg IBMblue) but what is the -sequence- command and how do you
> compute the parameter?
> Eg, contains
> *! version 1.0.0  22dec2002
> sequence 740
> set rgb "160 82 45"

Because you can specify an RBG value to obtain any color you wish, we
did not anticipate a large demand for creating named colors.
Regardless, you can indeed add your own named colors to Stata's
graphics.  For example, adding the file at the top
level of your SITE or PERSONAL directory with the contents,

---------------------- BEGIN --- --------------------
*! version 1.0.0  15feb2011
set rbg "20 20 179"
---------------------- END   --- --------------------

will create a new colorstyle, "myblue", that you can use anywhere a
colorstyle is accepted in graph commands.  For example,

    . scatter mpg weight, color(myblue)

See -help colorstyle- for a list of official named colors.

Allan asks about sequence numbers such as -sequence 740-.  Your .style
file does not need a sequence, but it may contain one.  The sequence
number determines the order in which named styles appear in graphics
dialog boxes and in the Contextual Toolbar of the Graph Editor.  So,
if you truly like your colorstyle, give it -sequence 1-.  It will then
appear at the top of any colorstyle list in the GUI.  (You will need to
either type -discard-, or restart Stata for your style to appear in the

I must warn Allan that there is another reason we did not document
creating your own named styles.  If you use "myblue" in a graph, save
the graph to disk, then share that graph file with a friend; you will
also need to share your .style file.  Otherwise, when your friend
-graph use-s your graph, the color "myblue" will not be found; Stata
will complain; and a default color, likely black, will be substituted.

-- Vince

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index