Announcement

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

  • force chart y-axis to start at 0

    Hi there

    I'm plotting y values on a chart which all happen to be zeros, and Stata insists on scaling the y-axis from -1 to 1 despite my use of the "range" option.

    Code:
    clear
    input int year float rate
    1999  0
    2000  0
    2001  0
    2002  0
    2003  0
    2004  0
    2005  0
    end
    line rate year, yscale(range(0 .)) ylabel(#5)
    Any advice on how else to force the y-axis to start at zero instead of -1 here?

    With many thanks


  • #2
    I think the code leaps into a special mode if the y variable is constant. I don't know how much of an improvement is gained by

    Code:
    line rate year, yscale(range(0 .)) ylabel(0)

    Comment


    • #3
      Specify a specific upper limit + restrict the plot region margin to 0.

      Code:
      line rate year, yscale(range(0, .1 )) ylabel(#5) plotregion(margin(0))
      Last edited by Andrew Musau; 19 Mar 2021, 08:22.

      Comment

      Working...
      X