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
Related Posts with Equal scaling on Y and X axes
select specific observation among several variablesHello everyone, Using STATA16, I have a dataset with 20 variables dx1 to dx20. I want to keep only …
Multivariate logistic regressioncode for Multivariate analysis …
loop over nested macroI want to plot many two-way plots, therefore I have many pairs of X's and Y's. I want to use macro …
descriptive statics: change the N from days to monthsHi, I'm trying to replicate the descriptive statics of a paper. The N of the descriptive statics is…
Split commandI imported a dataset from excel that had the structure …
Subscribe to:
Post Comments (Atom)
0 Response to Equal scaling on Y and X axes
Post a Comment