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

From |
"Garth Rauscher" <garthr@uic.edu> |

To |
<statalist@hsphsun2.harvard.edu> |

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

Date |
Mon, 20 Aug 2007 15:38:17 -0500 |

Thank you Nick for answering my two questions about graph labeling and sort order. Garth Rauscher Assistant Professor SPH Epidemiology and Biostatistics University of Illinois at Chicago 1603 W Taylor St (M/C/ 923) Chicago, IL 60612 (312) 413-4317 phone (312) 996-0064 fax garthr@uic.edu email -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: Thursday, August 16, 2007 12:28 PM To: statalist@hsphsun2.harvard.edu Subject: st: RE: Missing x-axis labels when using graph twoway #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 n.j.cox@durham.ac.uk 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/ * * 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/

**References**:**st: RE: Missing x-axis labels when using graph twoway***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: Upcoming NetCourses** - Next by Date:
**Re: st: GLLAMM modeling** - Previous by thread:
**st: RE: Missing x-axis labels when using graph twoway** - Next by thread:
**st: test post please ignore** - Index(es):

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