<>
Ulrich, which error messages did you receive? Antoine`s code runs for me when I add comments at the end of the lines belonging to the -twoway- commands...
*******
/*--------------------------------------------*/
clear
set scheme s2mono
use nlswork.dta, clear
g wage=exp(ln_wage)
su wage, de
drop if wage>r(p99)
egen t=group(year)
g ti=t+runiform()
g ti2=ti^2
g ti3=ti^3
qreg wage ti ti2 ti3
predict med
qreg wage ti ti2 ti3 , quantile(.95)
predict q95
qreg wage ti ti2 ti3 , quantile(.05)
predict q5
twoway (hist wage if t==1 , fcolor(gs14) plotr(m(zero)) ///
graphregion(margin(zero) color(white)) xlabel(0 "1") xtitle("") ///
ylabel(0(5)20, grid gmin gmax) horiz) (line med q95 q5 ti if t==1, sort ///
xaxis(2) yaxis(2) ylabel(0(5)20, axis(2)) lcolor(black black black) ///
lwidth(thick thick thick) lpattern(solid solid solid) xscale(off ///
axis(2)) yscale(off axis(2)) plotr(m(zero))) , legend(off) saving(a, ///
replace)
local list "a.gph"
local t=2
while `t'<=15 {
twoway (hist wage if t==`t', fcolor(gs14) plotr(m(zero)) ///
graphregion(margin(zero) color(white)) xlabel(0 "`t'") xtitle("") ///
yscale(off) xtitle("") ylabel(0(5)20 , grid gmin gmax) horiz) (line ///
med q95 q5 ti if t==`t', sort xaxis(2) yaxis(2) ylabel(0(5)20, axis(2)) ///
lcolor(black black black) lwidth(thick thick thick) lpattern(solid solid ///
solid) xscale(off axis(2)) yscale(off axis(2)) ) , legend(off) ///
saving(a`t', replace)
local list "`list' a`t'.gph"
local t=`t'+1
}
graph combine `list', imargin(0 0 0 0) row(1) graphregion(color(white)) ///
note(t, pos(6))
/*--------------------------------------------------*/
*********
HTH
Martin
-------- Original-Nachricht --------
> Datum: Fri, 20 Mar 2009 10:17:18 +0100
> Von: Ulrich Kohler <[email protected]>
> An: [email protected]
> Betreff: Re: st: [Graphics] how to set the length of an axis?
> Antoine,
>
> I got some error messages from your solution, but this one points you in
> a different direction and it arguably simpler. It calculates the numbers
> for the histogram by hand and uses -tw rbar- instead of -tw histogram-:
>
> ------------------------------------------------------cut here---
> clear
> set scheme s2mono
> webuse nlswork.dta, clear
> g wage=exp(ln_wage)
> su wage, de
> drop if wage>r(p99)
> egen t=group(year)
> g ti=t+runiform()
> g ti2=ti^2
> g ti3=ti^3
> qreg wage ti ti2 ti3
> predict med
> qreg wage ti ti2 ti3 , quantile(.95)
> predict q95
> qreg wage ti ti2 ti3 , quantile(.05)
> predict q5
>
> sum wage, meanonly
> gen wageclass = autocode(wage,20,r(min),r(max))
> by t wageclass, sort: gen wageperc = _N/r(N)
>
> // rescale wageperc
> sum wageperc, meanonly
> replace wageperc = wageperc/r(max) * .80
>
> gen lower = t
> gen upper = t + wageperc
>
> levelsof wageclass, local(K)
> local width = (`:word 2 of `K'' - `:word 1 of `K'')*.95
> twoway ///
> || rbar lower upper wageclass, ///
> color(gs12) barwidth(`width') horizontal ///
> || line med q95 q5 ti, sort lcolor(black..)
>
> -----------------------------------------------------------------
>
>
> Am Freitag, den 20.03.2009, 09:07 +0100 schrieb Antoine Terracol:
> > Dear _all,
> >
> > I was asked if I could reproduced a graphic like
> > http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109
> > in Stata.
> >
> > Using nlswork.dta, I was able to produce the graph whose code is pasted
> > below.
> >
> > As you can see, the years are not evenly spaced on the x-axis. In
> > particular, the part between "1" and "2" is much smaller than the rest.
> >
> > I understand that, in fact, the total width of the sub graphs are all
> > equal, and that the visual difference is due to the presence of the y
> > axis and its legend in the first sub-graph.
> >
> > Is there a way to set the length of the axis in the first sub graph, or,
> > alternatively, to produce a graph with just the y-axis in such a way
> > that it would look nice?
> >
> > Best,
> > Antoine
> >
> > /*--------------------------------------------*/
> > clear
> > set scheme s2mono
> > webuse nlswork.dta, clear
> > g wage=exp(ln_wage)
> > su wage, de
> > drop if wage>r(p99)
> > egen t=group(year)
> > g ti=t+runiform()
> > g ti2=ti^2
> > g ti3=ti^3
> > qreg wage ti ti2 ti3
> > predict med
> > qreg wage ti ti2 ti3 , quantile(.95)
> > predict q95
> > qreg wage ti ti2 ti3 , quantile(.05)
> > predict q5
> >
> > twoway (hist wage if t==1 , fcolor(gs14) plotr(m(zero))
> > graphregion(margin(zero) color(white)) xlabel(0 "1") xtitle("")
> > ylabel(0(5)20, grid gmin gmax) horiz) (line med q95 q5 ti if t==1, sort
> > xaxis(2) yaxis(2) ylabel(0(5)20, axis(2)) lcolor(black black black)
> > lwidth(thick thick thick) lpattern(solid solid solid) xscale(off
> > axis(2)) yscale(off axis(2)) plotr(m(zero))) , legend(off) saving(a,
> > replace)
> > local list "a.gph"
> >
> > local t=2
> > while `t'<=15 {
> > twoway (hist wage if t==`t', fcolor(gs14) plotr(m(zero))
> > graphregion(margin(zero) color(white)) xlabel(0 "`t'") xtitle("")
> > yscale(off) xtitle("") ylabel(0(5)20 , grid gmin gmax) horiz) (line
> > med q95 q5 ti if t==`t', sort xaxis(2) yaxis(2) ylabel(0(5)20, axis(2))
> > lcolor(black black black) lwidth(thick thick thick) lpattern(solid solid
> > solid) xscale(off axis(2)) yscale(off axis(2)) ) , legend(off)
> > saving(a`t', replace)
> > local list "`list' a`t'.gph"
> > local t=`t'+1
> > }
> > graph combine `list', imargin(0 0 0 0) row(1) graphregion(color(white))
> > note(t, pos(6))
> > /*--------------------------------------------------*/
> >
> > *
> > * 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/
> --
> [email protected]
> 030 25491-361
>
> *
> * 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/
--
Martin Weiss
Hackersteigle 3
72076 Tübingen
00497071/793535
00491784597218
Aufgepasst: Sind Ihre Daten beim Online-Banking auch optimal geschützt?
Jetzt absichern: https://homebanking.gmx.net/[email protected]
*
* 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/