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

Re: st: defining new colors or scheming too hard


From   vwiggins@stata.com (Vince Wiggins, StataCorp)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: defining new colors or scheming too hard
Date   Fri, 08 Oct 2004 13:42:54 -0500

Bill Rising <brising@louisville.edu> asks,

> I'd like to define a scheme, call it 'foo', to be able to easily
> switch the looks of graphs using something like
>
> -graph use nicegraph, scheme(foo)-
>
> When I went to poke through the scheme s2color.scheme, I found the
> following chunk of code:
>
> ---------------------------- cut here ----------------------------
> color background  ltbluishgray
> color foreground  black
> * do NOT use "r g b" numbers for background and foreground
> ---------------------------- cut here ----------------------------
>
> This gives the appearance that only named colors can be used for
> background and foreground colors. Unfortunately, there is no named
> color which matches the background color I'd like to use (this is
> just the first of the colors which need to be changed). Not only
> does "r g b" fail, but trying something like -red*.1- also fails.
>
> This brings me to my question: is there a way to define new named
> colors?


First, Bill can safely ignore the admonishment from scheme-s2color.scheme to

    "[...] NOT use "r g b" numbers for background and foreground"

This is a note to Stata developers (or as Bill says, those of the "mother
ship") not to try such shenanigans.  We don't want to do this because the
color would then be unavailable as a named color to use elsewhere.  It will
cause Bill no problems.

Using RGB values in scheme files does require that the RGB values be quoted,
so if Bill wants his background to be a nice dark pumpkin color, his
scheme-file entry should read

     color background  "255 100 50"

Bill may still decide he wants to create a named color to use for his
background.  It is really quite easy.  All Bill needs to do is create a file
of the proper name and place it along his adopath.  Here is an example where
we create the named color "dkpumpkin"

------------------------ BEGIN --- color-dkpumpkin.style --- CUT HERE -------
set rgb  "255 100 50"
------------------------   END --- color-dkpumpkin.style --- CUT HERE -------

The file is just a single line and I would suggest Bill place it in his
personal ado directory (type -sysdir- to find this directory), though anywhere
an ado-file would be found will work.

We can make color-dkpumpkin.style better,

------------------------ BEGIN --- color-dkpumpkin.style --- CUT HERE -------
*! version 1.0.0  09oct2004
sequence 9000
label "Pumpkin"
 
set rgb  "255 100 50"
------------------------   END --- color-dkpumpkin.style --- CUT HERE -------

The comment with the version at the top is just so we can track changes.  The
-sequence- number is an instruction to the graphics dialog boxes telling them
where to place "dkpumpkin" in drop-down lists of colors, and what follows
-label- is the text we want to appear in such drop-down lists.




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