7
$\begingroup$

I'm trying to draw a ListPlot where the x and y axis have the same scale.

My data is

{{100, 500}, {461/5, 473}, {548/5, 452}, {1459/10, 437}, {974/5, 428}, {250, 425}, 
 {1526/5, 428}, {3541/10, 437}, {1952/5, 452}, {2039/5, 473}, {400, 500}}

A simple ListPlot will result in:

Listplot no scale

where the x and y axis have a different scales.

I want them to force them to have the same scale. So far I've been able to achieve this only by explicitly setting PlotRange to the same value for x and y, and using AspectRation->1.

Example:

range := {Min[Flatten[x]], Max[Flatten[x]]}
ListPlot[x, PlotRange -> {range, range}, AspectRatio -> 1]

The result is:

List plot scaled

Questions:

  • Is there a Plot option to force the scale to be uniform? Do I always have to set the same range and AspectRatio to 1?

  • From the second image there is satisfying y ∈ [400, 500] and x < 100 with an x value that is lying outside of the drawing range. I thought by using the Min of all x and y this could not happen. What am I doing wrong?

$\endgroup$
1
  • 1
    $\begingroup$ AspectRatio -> Automatic. PlotRange in form {min, max} applies only to y axis. The x is Automatic, that's why the point is missing. $\endgroup$
    – Kuba
    Jul 10, 2014 at 7:49

1 Answer 1

1
$\begingroup$

As far as I know there is no other way besides setting the Options you describe, but there are many ways to make setting those Options more convenient. You can use SetOptions on ListPlot to make them the defaults, or you can use methods such as those shown here:

Regarding the BONUS: you must also set the AxesOrigin:

ListPlot[x,
 PlotRange -> {range, range},
 AspectRatio -> 1,
 AxesOrigin -> range[[1]]
]

enter image description here

$\endgroup$
5
  • 2
    $\begingroup$ ListPlot[x, PlotRange -> All, AspectRatio -> Automatic] $\endgroup$
    – Kuba
    Jul 10, 2014 at 7:57
  • $\begingroup$ @Kuba I don't think that's what the OP wants, at least as I read the question. $\endgroup$
    – Mr.Wizard
    Jul 10, 2014 at 8:00
  • $\begingroup$ I see, I think it is, but my interpretations "sometimes" fail. The range used by OP is equal for both axes only to make aspectratio->1 work, that's what I think. $\endgroup$
    – Kuba
    Jul 10, 2014 at 8:01
  • $\begingroup$ @Kuba In retrospect I can see that interpretation now too, and I think you are probably correct. Alas, wasted effort. But I'll wait for the OP to confirm before I Close. $\endgroup$
    – Mr.Wizard
    Jul 10, 2014 at 8:03
  • $\begingroup$ Thanks for the answers. I don't specifically need the same range, I was just trying to have the same scale on the x and y axis. It seems that Kuba's first comment to this answer does the trick, although at a first glance it might not seem so, as the ticks on the y have a different resolution than the ticks on the x. $\endgroup$
    – Marco83
    Jul 10, 2014 at 10:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.