1

R always makes x axis longer compared to the y axis, even if they both have the same limits. Is there an option to control the length of the axis?

plot(0:100,0:100)

enter image description here

I need it to be a square.

Liza
  • 1,066
  • 2
  • 16
  • 26
  • 4
    there is also`par(pty="s")` (from http://stackoverflow.com/questions/8693558/how-to-define-fixed-aspect-ratio-for-scatter-plot) – user20650 Feb 10 '16 at 01:01
  • If you save your plots with equal height and width, they'll also end up square: `png('~/Desktop/Rplot.png'); plot(0:100, 0:100); dev.off()` (`png` default height and width are both 480px.) – alistaire Feb 10 '16 at 01:37

1 Answers1

5

Yes, at least if you are using base graphics. The asp argument should be set to 1:

plot(0:100,0:100, asp=1)   # see ?plot.default

The duplicate that Ben found also has

plot(0:100,0:100, pty="s")
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • isn't this a duplicate of http://stackoverflow.com/questions/8693558/how-to-define-fixed-aspect-ratio-for-scatter-plot?lq=1 ? – Ben Bolker Feb 10 '16 at 01:06
  • Yeah. I didn't remember my prior answer. And didn't follow user65250's link. – IRTFM Feb 10 '16 at 01:59