In fact, you don't need any of this new class stuff.
-histogram- is already prepared to think that
it has a second x axis.
Here is another take, this time using -mylabels-
from SSC to get the label positions:
. sysuse auto
. su mpg
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
mpg | 74 21.2973 5.785503 12 41
. mylabels -1/3, myscale(21.2973 + (@) * 5.788503) local(LABELS)
15.5088 "-1" 21.2973 "0" 27.0858 "1" 32.8743 "2" 38.6628 "3"
. histogram mpg, xaxis(1 2) xla(`LABELS', axis(2)) xtitle(z scale, axis(2))
(bin=8, start=12, width=3.625)
Here I knew from the earlier graph that a sensible range was -1 to 3 on
the z scale.
Nick
[email protected]
Nick Cox
> In the same spirit, and standing on Vince's shoulders (*),
>
> ------------------------------- myhistogram.do
> qui su `0'
> local imin = ceil((r(min) - r(mean))/r(sd))
> local imax = floor((r(max) - r(mean))/r(sd))
> forval i = `imin'/`imax' {
> local labels `"`labels' `= r(mean) + (`i') * r(sd)' "`i'" "'
> }
> set graphics off
> histogram `0', t1(z scale)
> .Graph.insert (.xaxis2 = .axis.new , position(above)) above
> plotregion1
> .Graph.set_axis_plotregion xaxis2 plotregion1 x
> .Graph.xaxis2.major.add_ticks `labels'
> set graphics on
> graph display
> -----------------------------------
>
> This should work as follows:
>
> do myhistogram systolic
> do myhistogram systolic if female
>
> etc.
>
> Nick
> [email protected]
>
> (*) A book on catastrophe theory bore a dedication to a
> beloved mentor:
> "at whose feet we sit, on whose shoulders we stand". Only
> topologists could
> visualise the resulting position.
>
> Christopher F Baum
>
> > Please see Vince Wiggins' talk from the London meetings, where he
> > presented code to do something like that in the example using US
> > states.
> >
> > http://ideas.repec.org/s/boc/usug04.html
> >
>
> Richard T. Campbell
>
> > > For teaching purposes,I would like to display a histogram with
> > > overlaid normal density. I would like to display two x
> axes on this
> > > graph, one in the scale of the original variable, say
> systolic blood
> > > pressure and the other in the Z transform of that variable I can't
> > > seem to figure out how to do that. Can someone help?
>
*
* 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/