Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Combining two graphs with the same y-axis but with/without xlabels (50% solved)


From   Scott Merryman <scott.merryman@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Combining two graphs with the same y-axis but with/without xlabels (50% solved)
Date   Sun, 18 Mar 2012 15:20:59 -0500

You can use the  forced size option -fxsize()-

sysuse citytemp, clear

cap graph drop left right

scatter region tempjan ,  ytitle("") ylab( , valuelabel grid) ///
 plotregion( margin(large)) plotregion(style(none)) name(left) ///
 xtitle(" ") xla( ,  labcolor(white) tlcolor(none))  ///
 fxsize(30)  graphregion(color(white))

scatter region tempjuly,  ytitle("") yscale(off) ///
 plotregion(margin(large) )plotregion(style(none)) name(right)
 ysc( noline ) graphregion(color(white))

graph combine left right, ycommon col(2) ///
  graphregion(color(white)) imargin(0 0 0 0)


Scott


On Sun, Mar 18, 2012 at 12:39 PM, Bert Jung <bjung59@gmail.com> wrote:
>
> Dear Statalisters,
>
> I am combining two graphs with the same y-axis.  The right graph will
> have value labels and ticks on the x-axis, but the one on the left
> other won't.  (I realize this sounds strange but there's a good
> reason.)
>
> I encountered two problems, one of which I have solved.
>
>
> * (1) Aligning the y-axsis.  -graph combine- supports the use of a
> common y-axis but the axis don't align in the final output: the left
> axis extends further down, presumably because of the space savings
> from omitting the valuelabels and ticks.  My solution is to use an
> empty -xtitle- along with white labels and invisible ticks.  The
> result is below and alings as intended.
>
> I am unclear why -labcolor(none)- produces black-colored labels when
> it should really be invisible, but I can live with using white.
>
>
> * (2) I would like to limit the width of the left-hand graph, so that
> the final output is dominated by the right-hand graph.  I can use
> -aspectratio- to make the left-hand side graph slimmed but -graph
> combine- will still give it half of the space in the final output.
>
>
> Any ideas on how to solve item (2) are much appreciated.
>
> Cheers,
> Bert
>
>
> sysuse citytemp, clear
>
> cap graph drop left right
>
> scatter region tempjan , /*
>        */ ytitle("") ylab( , valuelabel    grid ) plotregion(
> margin(large)
> ) plotregion(style(none))  /*
>        */ name(left) /*
>        */ xtitle(" ")  /*
>        */ xla( ,  labcolor(white) tlcolor(none)) aspectratio(5)
>
> scatter region tempjuly, /*
>        */ ytitle("") ylab( , nolabel    grid ) plotregion( margin(large) )
> plotregion(style(none))  /*
>        */ name(right) /*
>        */ ysc( noline )
>
> graph combine left right, ycommon col(2)

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index