Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: placing -xtitle- in a specific location in relation to the scale of the x-axis


From   Jacob Wegelin <[email protected]>
To   [email protected]
Subject   st: placing -xtitle- in a specific location in relation to the scale of the x-axis
Date   Sun, 3 May 2009 12:03:36 -0400

Is there a way to specify the horizontal location of the -xtitle- in
relation to the scale of the x-axis?

For instance, in the example below, for beauty of presentation I'd
like to place the -xtitle- exactly at the midpoint between the
quartiles of -mpg-. The code below *almost* does this, by calling both
-xlabel- and -xmlabel- and pretending that my x-axis title marks a
value on the x-axis. But the result is that the text "MPG" is too
close to the plot region, i.e., too high up, squeezed between the
numeric axis labels. It should lie below the numeric axis labels. If
the text were "Miles per gallon" it would not fit between the numeric
axis labels at all.

Also, if one wanted to create two honest numeric axis labels (-xlabel-
and -xmlabel-), I think the following workaround might interfere.

Is there a way to specify straightforwardly that one wants one's
-xtitle- to be located, for instance, where x==21.5 and a specific
distance below the plot region?

The graph editor allows me to place the -xtitle- at the far left
("southwest") or far right ("southeast") but does not seem to allow a
specific numeric location with respect to the x-axis.

sysuse auto, clear
qui summarize mpg, detail
local thisQ1=r(p25)
local thisQ3=r(p75)
local xtitlelocation= (`thisQ1'+`thisQ3')/2
di `xtitlelocation'
sort mpg
kdensity mpg , gen(dnsMPGx dnsMPGy) nograph
set scheme lean1
twoway (line dnsMPGy dnsMPGx) ///
   , xlabel(`xtitlelocation' "MPG", nogrid noticks labsize(large)) ///
   xmlabel(`thisQ1' `thisQ3', grid glpattern(dash) labsize(medium)) ///
   xtitle("") ///
   plotregion(margin(zero)) ///
   title("") ytitle("") ylabel(none)


Thanks for any insights

Jacob A. Wegelin
Assistant Professor
Department of Biostatistics
Virginia Commonwealth University
730 East Broad Street Room 3006
P. O. Box 980032
Richmond VA 23298-0032
U.S.A.
E-mail: [email protected]
URL: http://www.people.vcu.edu/~jwegelin

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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