Hi there
I'm plotting several graphs using the -line- command and the by() option.
I like how Stata automatically scales the y-axes to fit the line graphs nicely when plotting each sex separately:
line rate year if sex == 1, yscale(range(0 .)) ylabel(#5)
line rate year if sex == 2, yscale(range(0 .)) ylabel(#5)
But when I use the by() function to plot the graphs side by side, the y-axes are the same for each graph:
line rate year, by(sex) yscale(range(0 .)) ylabel(#5)
Of course this is a sensible default, but for my purposes I would like each graph's y-axis to be scaled just as it is when plotting each sex separately.
Any tips on how to achieve this?
With many thanks
I'm plotting several graphs using the -line- command and the by() option.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte sex int year float rate 1 1999 0.5 1 2000 1.5 1 2000 2.0 1 2002 2.3 1 2003 2.5 1 2004 3.0 1 2005 3.4 2 1999 17.5 2 2000 22.5 2 2001 27.5 2 2002 32.5 2 2003 37.5 2 2004 42.5 2 2005 47.5 end
line rate year if sex == 1, yscale(range(0 .)) ylabel(#5)
line rate year if sex == 2, yscale(range(0 .)) ylabel(#5)
But when I use the by() function to plot the graphs side by side, the y-axes are the same for each graph:
line rate year, by(sex) yscale(range(0 .)) ylabel(#5)
Of course this is a sensible default, but for my purposes I would like each graph's y-axis to be scaled just as it is when plotting each sex separately.
Any tips on how to achieve this?
With many thanks
Comment