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

Re: st: seriesstyle


From   [email protected] (Vince Wiggins, StataCorp)
To   [email protected]
Subject   Re: st: seriesstyle
Date   Tue, 08 Apr 2003 13:15:32 -0500

Friedrich Huebler <[email protected]> asks about cycling through the
styles of connected lines when he has 28 different lines on a graph,

> I am combining data for 28 countries in one graph like this:
>
> scatter gpi_totl total if country=="Benin", msymbol(O) connect(l) ||
> scatter gpi_totl total if country=="Bolivia", msymbol(O) connect(l)
> ||
> [repeat same command for 26 other countries]
>
> Stata returns the following message and draws the lines and data
> points for countries 16 to 28 in the same color as country 1:
>
> (note: seriesstyle p16 not found in scheme, default attributes used)
> (note: seriesstyle p17 not found in scheme, default attributes used)
> [message repeated for seriesstyles p18 to p28]

Friedrich goes on to note that the [G] manual contains no reference to
-seriesstyle- and that the implied suggestion of the error message is to try
something like

> scatter gpi_totl total if country=="Benin", [...] seriesstyle(p1)

which results in an error message.

The notes are confusing and this is why Friedrich's use of -seriesstyle(p1)-
fails.  The notes should refer to -pstyle()-s, which are documented in the
manual, but instead refer to the internal name of these styles,
-seriesstyles-.  The notes should read, e.g.,

   (note: pstyle p16 not found in scheme, default attributes used)

and this will be changed in the next ado update.  Armed with that information,
Friedrich's solution will work

   .  scatter gpi_totl total if country=="Benin", [...] pstyle(p1)

Given the complexity of Friedrich's graph command, adding a pstyle() option to
each plot past 16 is relatively easy, but what he really wanted was for
-graph- to automatically rotate back through the -pstyle-s in a manner similar
to -graph7-,

> How can I force Stata to use seriesstyle p1 for country 16,
> seriesstyle p2 for country 17, and so on? I would like to rotate
> colors and not repeat the same color again and again.

In Stata 7 and earlier, this cycling was done directly in C code and could not
be controlled by the user.  With the new graphics, there is more flexibility
and more control, but no concept of automatic cycling, instead the -pstyle-s
are under control of the .scheme file.  Schemes have been discussed on the
list before, so I won't belabor what they are, see [G] schemes for an overview
of what can be done with schemes.  We can create a new scheme that will mimic
the cycling behaviour of old Stata graphics,

---------------------------------- BEGIN --- cycle.scheme --- CUT HERE -------

* A scheme to repeatedly cycle through 16 pstyles

#include s2color

seriesstyle p17 p1
seriesstyle p18 p2
seriesstyle p19 p3
seriesstyle p20 p4
seriesstyle p21 p5
seriesstyle p22 p6
seriesstyle p23 p7
seriesstyle p24 p8
seriesstyle p25 p9
seriesstyle p26 p10
seriesstyle p27 p11
seriesstyle p28 p12
seriesstyle p29 p13
seriesstyle p30 p14
seriesstyle p31 p15
seriesstyle p32 p16

seriesstyle p33 p1
seriesstyle p34 p2

----------------------------------   END --- cycle.scheme --- CUT HERE -------

The #include directive means that cycle.scheme is to be based on the -s2color-
scheme, the default scheme when Stata is shipped.  The remaining lines just
designate that as new plots are drawn, cycle back to p1 for the 17th plot etc.
I stopped at 34 lines, but could have continued.  You can see that the
scheme-files use the internal name seriesstyle for pstyles; that is
unfortunate, but is currently the only way to refer to pstyles in a
scheme-file.

Note that there is nothing magical about the 16 -pstyle-s that were shipped
with Stata; we are pretty much stretching the limits of easily distinguishable
colors.  Friedrich might decide that Stata had it right prior to Stata 8 and
should start cycling after 8 pstyles.  That would be more like,

      seriesstyle p9  p1
      seriesstyle p11 p2
      seriesstyle p12 p3
      seriesstyle p13 p4
      seriesstyle p14 p5
      seriesstyle p15 p6
      seriesstyle p16 p7
      seriesstyle p17 p8
      seriesstyle p18 p1
      ...

or, he might like to switch up the order in which the -pstyle-s are applied.

      seriesstyle p1  p12
      seriesstyle p2  p1
      seriesstyle p3  p5
      ...

You will have to take my word that this is the way to create cycle.scheme.  We
did not document the format or content of the scheme-files in [G].  The new
graphics already had plenty of documentation to assimilate and we wanted to
retain the flexibility to reorganize the scheme-files based on user reaction
to the new system.  We now consider it "safe" to document the scheme-files, so
look for documentation fairly soon, say within 3 weeks.

To use the new scheme, Friedrich will need to place the cycle.scheme file in
his personal ado directory (type -sysdir- to find the location of that
directory) and type -set scheme cycle- or use the -scheme(cycle)- option of
-graph-.


-- Vince
   [email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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