Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Missing x-axis labels when using graph twoway


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Missing x-axis labels when using graph twoway
Date   Thu, 16 Aug 2007 18:27:30 +0100

#1 

Value labels are not shown by default. You 
must specify (e.g.) -xla(, valuelabel)-, as is 
documented in the help for axis_label_options. 

#2 

Consider 

. sysuse auto
. scatter mpg weight 
. sort mpg 
. scatter mpg weight 

The -sort- affects the sort order of the data, but 
is irrelevant to the scatter plot, which is 
unchanged. What you asked for "did work"; the 
problem is in your expectations. You can't do 
a scatter plot versus weight using the sort order
of mpg because it would no longer be a scatter plot
versus weight. (You can connect points in that order, 
but that is a different story.) 

In a simpler analogue of your data 

users_meeting_venue          order_in_2007

Essen                        1
Boston                       2
Stockholm                    3 
London                       4
Roma                         5 
Los Angeles                  6 

If you -encode users_meeting_venue- you get  

encoded users_meeting_venue          order_in_2007

value 1 label Boston                       2
value 2 label Essen                        1
value 3 label London                       4
value 4 label Los Angeles                  6
value 5 label Roma                         5 
value 6 label Stockholm                    3 

But really what you want to do is to attach the names
as labels to -order_in_2007-! 

One solution to your problem to the -egen- function
-axis()- in -egenmore- from SSC. You create 
a new variable like this: 

egen x_axis = axis(_se study), label(study) 

and then use -x_axis- as your x axis variable, 
not -study-. 

It may well be that 

egen x_axis = axis(_se), label(study) 

is enough, but what I wrote first includes
protection against ties on standard error. 

Nick 
[email protected] 

Garth Rauscher
 
> I have two probably simple questions about graphing in Stata. 
> #1 involves
> getting value labels to appear on the x axis. #2 involves 
> sorting the graph
> on a variable other than the x-axis variable.
> 
> 
> #1
> I have a dataset where each observation contains a string variable
> ("study_") and a point estimate and lower and upper confidence limits
> associated with a single study. I want to plot these estimates and
> confidence intervals, with magnitude of each estimate on the 
> y-axis and
> study information on the x axis. Apparently string variables 
> are not allowed
> with graph twoway, so I encoded a numeric variable (named 
> study) from the
> original string variable (named study_), containing the 
> original strings as
> value labels.
>  
> 
> encode study_, generate(study)
> 
> 
> This appears to have worked just as expected:
> 
> groups study study_ 
> 
>                      study                         study _    
>       Freq.
> Percent |
>  
> |-------------------------------------------------------------
> --------------
> ------|
>   |         BROWN (1992) WOM(0.2)           BROWN (1992) 
> WOM(0.2)       1
> 5.26 |
>   |        CAPLAN (2003) TOTAL(2)          CAPLAN (2003) 
> TOTAL(2)       2
> 10.53 |
>   |        DEGNAN (1992) TOTAL(2)          DEGNAN (1992) 
> TOTAL(2)       1
> 5.26 |
> 
> 
> 
> groups study study_, nolabel
> 
>     study                 study _           Freq.   Percent |
>   |---------------------------------------------------------|
>   |     1           BROWN (1992) WOM(0.2)       1      5.26 |
>   |     2          CAPLAN (2003) TOTAL(2)       2     10.53 |
>   |     3          DEGNAN (1992) TOTAL(2)       1      5.26 |
> 
> 
> 
> However, when I go to graph these estimates using the numeric variable
> study, the value labels for study do not appear on the x-axis.
> 
> scatter _se study || rcap hi_se lo_se study 
> 
> 
> #2 I'd like to sort the graph in order of ascending standard 
> error of the
> estimate.
> 
> Neither.....
> 
> sort _se
> scatter _se study || rcap hi_se lo_se study 
> 
> Nor....
> 
> scatter _se study, sort(_se) || rcap hi_se lo_se study 
> 
> Nor....
> 
> scatter _se study, sort(_se) || rcap hi_se lo_se study, sort(_se)
> 
> Will work.
> 

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