Combining graphs for the same x axis length but when y values have different lengths

Viewed 283

I think this question differs from a few solutions I've seen. I am attempting to stack two graphs together, and the range of the x-axis is the same between graphs. However, for the 2nd graph on the bottom, the values that are in the y-axis are much larger, which shrinks the x-axis.

I was wondering whether anyone knew how to do two different things, each of which involves at a minimum forcing the x-axis to be the same length between graphs:

(a) If the x-axis is equal between graphs, and allowing for the same spacing between the y axis numbers and the y axis label, such that there would be more white space to the left of the y label on the top graph in the combined image;

(b) If the x-axis is equal between graphs, which can push out the y-label in the bottom graph, and asking for there to be enough white space in the top graph between the y label and the y values so that the y labels are aligned with each other.

If anyone can help with these two variations, I would be very grateful. The code is below.

use http://www.stata-press.com/data/r13/wpi1.dta, clear
g wpi10 = wpi * 100 

twoway scatter wpi t, ylabel(, angle(0))
graph save 1, replace

twoway scatter wpi10 t, ylabel(, angle(0))
graph save 2, replace
    
graph combine 1.gph 2.gph, cols(1)
1 Answers

graph combine can be a pain to use, so it's better to avoid using it. Try to use by instead.

use http://www.stata-press.com/data/r13/wpi1.dta, clear
g wpi10 = wpi * 100 
rename (wpi wpi10) value=
drop ln_wpi
reshape long value, i(t) j(variable) string

twoway scatter value t, ylabel(, angle(0)) by(variable, cols(1) yrescale)
Related