Announcement

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

  • Equal scaling on Y and X axes

    This seems so basic and obvious but I can't find a discussion online or in documentation. I want a scatterplot with the same physical scaling on Y and X axes. I've done mca and mcaplot does this, but I want other plots of dimensions. As the ranges of Y and X differ, aspect(1) gives equal length axes but not equal scales. This brute force code gives an approximate solution, but is based on the data values and the plotted axes have an extra space outside the plot area which I think has to be allowed for. Also the axes use rounded (nice) labels which may also affect the scaling. The best solution (to me!) would be a new option "aspect(xyequal)"!

    After mca, the coordinates have to be extracted from a matrix:
    matrix A=e(A)
    svmat2 A, names(dim1 dim2 dim3) rnames(varnam) full
    qui sum dim1
    scalar xhi=r(max)
    scalar xlo=r(min)
    qui sum dim2
    scalar yhi=r(max)
    scalar ylo=r(min)
    local asrat=(yhi-ylo)/(xhi-xlo)
    scatter [lots omitted] ... aspect(`asrat')

    Allan

  • #2
    You may need all three of these conditions:

    1. specified aspect ratio

    2. specified axis ranges using ysc() xsc()

    3. all data falling within #2 as an axis scale option will never make Stata omit data.

    Comment


    • #3
      Well yes. The easiest would be yrange=xrange and aspect(1). Which is easy to do by inspection but I'm putting this in a .do file and it's not obvious how to automate it.

      Comment


      • #4
        Complete generality is hard here. In practice, if the limits are not clear in advance I would use summarize, meanonly and also nicenum

        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.

        Comment

        Working...
        X