Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • line graph, by() on different y-axis scales

    Hi there

    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
    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

  • #2
    Code:
    line rate year, by(sex, yrescale) yscale(range(0 .)) ylabel(#5)

    Comment


    • #3
      brilliant - thanks!

      Comment


      • #4
        Your data example doesn't, to me, rule out the possibility that logarithmic scale might help.

        Comment

        Working...
        X