Statalist The Stata Listserver


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

RE: st: Controlling alignment of left axis in -graph combine-d graphs


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   RE: st: Controlling alignment of left axis in -graph combine-d graphs
Date   Mon, 5 Feb 2007 08:07:43 -0600

I don't know if there is still interest in this problem, but adjusting the
-ylabel()- margin as a function of the difference in maximum widths of the
two ylabels appears to work.

For example:

clear
set obs 100
gen x = uniform()
gen y1 = uniform()*10
gen y2 = uniform()*100
gen y3 = uniform()*400
gen y4 = uniform()*90000

foreach i of numlist 1 3 {
qui sum y`i'
_natscale `=r(min)' `=r(max)' 5
local m`i' = r(max)
local l`i' = length("`m`i''") 

local j = `i' + 1
qui sum y`j'
_natscale `=r(min)' `=r(max)' 5
local m`j' = r(max)
local l`j' = length("`m`j''") 
local diff = (`l`j''- `l`i'')*2 

display "lengths: " "`l`i'' `l`j'' `diff'"

scatter y`i' x, ylabel(,angle(h)) xlabel(none) xtitle("") /// 
 ytitle(, margin(0 `diff'  0 0 )) name(gr1, replace)
scatter y`j' x, ylabel(,angle(h)) name(gr2,replace) /// 
 ytitle(, margin(0 0 0 0 ))
graph combine gr1 gr2, col(1) name(gr_`j', replace)
graph drop gr1 gr2
}

Scott

> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of David Elliott
> Sent: Thursday, February 01, 2007 10:52 AM
> To: [email protected]
> Subject: Re: st: Controlling alignment of left axis in -graph combine-d
> graphs
> 
> Thank you, Svend.  Incidently, I use your lean schemes for some of my
> graphs.  For the time being I think I will stick to my workaround as I
> am creating graphs for a non-technical audience and they need to look
> as much like "business graphics" *shudder* as possible.
> 
> On a more philosophical note:  Should we not be able to specify a
> width for the axis labels?  Or have the implicit width of format() be
> used as the width for the axis labels?  I think this should be given
> some consideration by Stata.  We can, for example, control legend
> width with textwidth().  It would be possible to do the same thing
> with a labelwidth() property, I should think. The only downside of a
> label overflow would be having the label very close to or overprinting
> the {x|y}title.
> 
> DCE



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