----- Original Message -----
From: "Grote, Veit Dr." <Veit.Grote@kk-i.med.uni-muenchen.de>
To: <statalist@hsphsun2.harvard.edu>
Sent: Thursday, August 21, 2003 8:44 AM
Subject: st: xlabels and graph with 2 y-axis
> Hello,
> I have a simple graph that does not come out as I want to (Stata 8.1).
> I have a labeled categorical variable which I would like to use as my x-axis,
and two numerical variables of different scales (2 y-axis). One should be
expressed in bars and one as a line/connected line (as in the frequency polygon
example in Statalist just recently).
>
> 1. First problem: Why is the scale of the bars cut (in my data at 30, so that
the lower range 0-30 is not displayed) whereas the scale of the 2nd y-axis is
for the whole range of the data? OK, I fixed that with options scale/range.
> 2. Second problem: I am unable to display the labels of the x-axis? What is
the trick? One desperate try was:
>
> twoway bar y1 x || connected y2 x, xlabel(#7, valuelabels) yaxis(2)
>
> Thanks for your help
> Veit Grote
>
To display the labels on the x-axis I believe you want the option: xlabel(,
valuelabel)
(You can find the option on the x-axis tab in the twoway dialog)
For example, the following will label the x-axis with "poor", "ok" ,....
. use "C:\Stata8\auto.dta", clear
(1978 Automobile Data)
. label define rep 1 poor 2 ok 3 average 4 good 5 excellent
. label values rep78 rep
. egen average_price = mean(price), by(rep)
. twoway (bar mpg rep78, sort xlabel(, valuelabel)) (line average_price rep,
sort yaxis(2))
Hope this helps,
Scott
*
* 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/