Announcement

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

  • Understanding Stata's default yscale() choice

    Hi everyone,

    I am trying to find out how Stata chooses the exact default range of the y-axis. The article "Stata tip 23: Regaining control over axis range" (The Stata Journal (2005), 5, Number 3, pp. 467-468) notes that "to determine the range of an axis, Stata begins with the minimum and maximum of the data. Then it will widen (but never narrow) the axis range as instructed byrange(). Finally, it will widen the axis if necessary to accommodate any axis labels."

    Does anyone have additional insights on how Stata determines how much white space to leave below the minimum and above the maximum respectively for a simple plot command without additional user-specifications?

    Many thanks,
    Christina


  • #2
    I can't easily add to that. Back in the day James Hardin, then working for what is now StataCorp, published a command that appears similar in spirit but not always in outcome to what Stata now does to choose axis labels.

    dm28 from http://www.stata.com/stb/stb25
    STB-25 dm28. Calculate nice numbers for labeling or drawing grid lines. /
    STB insert by James Hardin, Stata Corporation. / Support:
    [email protected] / After installation, see help nicenum.

    The precise algorithm might well be a little too complicated to explain. The trade-off between too many and too few labels and how far numbers can be shown that are nice -- typically multiples of 1, 2, 5 -- is delicate. Yet again, there is usually a bias to showing zero on each axis but if you ask for zero and a logarithmic scale too, Stata doesn't call that illegal: it just gives you an awful graph.

    Comment


    • #3
      Hi Nick,

      Thank you very much for this fast and helpful reply, it is greatly appreciated!

      Best,
      Christina

      PS: Updated link to dm28 as per Nick's post: https://www.stata.com/products/stb/journals/stb25.pdf

      Comment

      Working...
      X