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

st: RE: Controlling look of variable labels in onewayplot


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Controlling look of variable labels in onewayplot
Date   Tue, 3 Aug 2004 22:54:34 +0100

A small point is that here the 
values of the argument of -by()- are 
serving as value labels on one axis on 
-onewayplot-. Variable labels do not 
enter this question, as variable labels 
will never be displayed _as value labels_ 
when -onewayplot- is used with -by()-. 
The -variablelabels- option remains legal 
but it is ignored. Perhaps the author 
of -onewayplot- should trap that, but it seems 
fairly harmless in itself. 

A larger point is that this is nothing to
do with -onewayplot- as such. It is generic
to -graph-. In particular, -onewayplot- 
is just a wrapper to -scatter- and does 
nothing special to values. The behaviour
may be seen otherwise. For example, 

. sysuse auto, clear

Pad out -make- with spaces at the end: 

replace make = make + substr(`"`: di _dup(18) " "'"', 1, 18-length(make))

Now try to use that: 

graph dot (asis) mpg if foreign, over(make)

The trailing spaces all get stripped. 

The only way I know round this is ugly 
beyond acceptance. Add a barrier character
at the end: 

replace make = make + "|" 
graph dot (asis) mpg if foreign, over(make)

Now the spaces are shown. But even if the 
barrier were not visible, we would still
have the problem that almost all of the 
acceptable fonts for graphs use differing 
amounts of space for each character, so 
the names would not line up well in any 
case (or, in any font). 

In short, I can't solve your problem, 
but I can offer this diagnosis. 

Nick 
[email protected] 

That example on p.76 would look better
if the y axis ticks were all suppressed. 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of 
> David Harless
> Sent: 03 August 2004 21:45
> To: [email protected]
> Subject: st: Controlling look of variable labels in onewayplot
> 
> 
> In Stata Journal Volume 4(1) page 76, I saw the nice example 
> using onewayplot in 
>   Nick Cox's "Speaking Stata" column.  I am trying to use 
> onewayplot but control 
> how the "byvar" label looks.  My byvar is named dec_all and 
> I've put in extra 
> spaces to make the value labels line up a certain way -- at 
> least in a 
> fixed-width font:
> 
> . table dec_all
> ------------------------------
>            dec_all |      Freq.
> ------------------+-----------
>          <    3.77 |     14,665
>      3.77-   11.67 |      4,228
>     11.67-   38.75 |      2,208
>     38.75-   50.08 |        689
>     50.08-   60.23 |        502
>     60.23-   76.93 |        491
>     76.93-  140.19 |        410
>    140.19-  248.67 |        347
>    248.67-2,476.99 |        186
> 2,477.00<         |         22
> ------------------------------
> 
> I'd like to make the labels keep this approximate 
> relationship when I used the 
> variablelabels option in onewayplot, but when I issue the 
> following command
> 
> onewayplot myvar , by(dec_all) stack  msize(*.75) ///
> 	variablelabels ytitle("")  ms(oh)
> 
> I find that
> (i) my labels are partly cut-off (e.g. ".67-2,476.99" instead of 
> "248.67-2,476.99") and
> (ii) my labels are all right-justified against the y axis 
> instead of looking 
> something like they do in the table above.
> Any suggestions on how to handle this?
> 
> Thanks,
> Dave Harless
> 
> 
> 
> *
> *   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/
> 

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