Announcement

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

  • How to include zero in range for rescaled axis on time series -by- plot? [Stata version: 14.2]

    I've been working on a by-group time series plot and have rescaled the yaxis given the different value ranges within the group. However, I don't seem to be able to include a zero in the axis range.

    For example
    Code:
    sysuse xtline1
    tsset person day
    tsline calories if day>=td(22oct2002) & day<=td(31dec2002),by(person, col(1)) ylab(#4, angle(0)) ysc(range(0))
    gives the plot including the zeros in the range of the y-axis.

    I want to rescale the y axes because the data I have is quite different by value in the by panel.

    For example, let's put Sam on a diet and rescale the y axis in the resulting plot

    Code:
    replace calories=calories/3 if person==2
    tsline calories if day>=td(22oct2002) & day<=td(31dec2002),by(person, col(1) yrescale) ylab(#4, angle(0)) ysc(range(0))
    After having done this, I can't seem to control the range to include zero. The -range(0) seems to have no effect and placing it in the by statement gives an error.

    Do I have any options to control the range of the rescaled axis to include zero (there are no valid zeros in the data I'm using).

    Thanks for any help. I could recreate this panel graph by graphing independently and combining the graphs, but it would be handy not to do that.

    -cam

  • #2
    I think Stata is ignoring ysc() because yrescale already tells it to use each group's data to determine limits.

    You can insist on ylabel(0) but then you'll probably cancel the rescaling at best.
    Last edited by Nick Cox; 19 Jul 2017, 09:43.

    Comment


    • #3
      Thanks Nick. I suspected that was what is happening.

      Comment

      Working...
      X