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

Re: st: Parse graphsize from schemes into program


From   [email protected] (Vince Wiggins, StataCorp)
To   [email protected]
Subject   Re: st: Parse graphsize from schemes into program
Date   Fri, 18 Jun 2004 14:09:58 -0500

Uli Kohler <[email protected]> asks about reading the default graph size
from the current graphics scheme,

> in a program I want to set the default xsize() of a graph equal to
> the -graphsize y- of the scheme.
>
> Is there a way to read the default graph size from the scheme which
> is actually loaded?


The concept of a current scheme is rather plastic in the graphics environment.
For example, it is possible to -graph combine- two graphs drawn with different
schemes and for those graphs to maintain their original schemes.

It is safest for Uli to first draw a graph using the desired scheme, then pull
the size from the graph's own scheme object.  For example, after

      . scatter mpg weight , nodraw

Uli, could type

      . di `.Graph._scheme.graphsize.y'

to see the default graph y size for the scheme, or

      . local ysize `.Graph._scheme.graphsize.y'

to put that size in a local macro.

We are doing nothing more more than pulling the value of an sub-object from
within the object that holds our graph.  Because we did not name our graph, it
is named "Graph" and that is where we got the first part of the name

      .Graph._scheme.graphsize.y
       ^^^^^

All graph hold a reference to the scheme they were drawn with in the
sub-object _scheme

      .Graph._scheme.graphsize.y
             ^^^^^^^

Schemes all define a graphsize sub-object

      .Graph._scheme.graphsize.y
                     ^^^^^^^^^

And it contains the x and y size of the graph

      .Graph._scheme.graphsize.y
                               ^

In Stata, this nested name can be treated just like a local macro name and
dereferenced using macro quotes, and that is how we fetched the value

      `.Graph._scheme.graphsize.y'
      ^                          ^


-- 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