Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

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

From   Bert Jung <[email protected]>
To   [email protected]
Subject   st: Combining two graphs with the same y-axis but with/without xlabels (50% solved)
Date   Sun, 18 Mar 2012 13:39:33 -0400

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

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.


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:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index