I'm plotting the shortest distance from a point to a line using the following code

Show[Plot[1/2 x + 1/2, {x, -6, 7}], 
     ListPlot[{{4, -2.5}, {2, 1.5}}, Joined -> True, PlotMarkers -> Automatic]]

As this is the shortest line from the point to the line, the angle between the two lines should be 90 degrees. It doesn't show up like that in Mathematica, however, since the y-axis is incrementing in visually smaller steps than the x-axis.

How can I get Mathematica to automatically to use even steps on the two axes?

  • 1
    $\begingroup$ Look up AspectRatio. $\endgroup$ May 10, 2013 at 13:14
  • $\begingroup$ I'm aware of AspectRatio, but it's not what I'm looking for. AspectRatio simply stretches the graphics but I'm fine with it's current size. $\endgroup$
    – paldepind
    May 10, 2013 at 13:18
  • 2
    $\begingroup$ Even if you set AspectRatio -> Automatic? $\endgroup$ May 10, 2013 at 13:21
  • $\begingroup$ You are absolutely right! Automatic does indeed work! $\endgroup$
    – paldepind
    May 10, 2013 at 13:28
  • $\begingroup$ Read up on what that option does, and then you can write an answer to your own question. :) $\endgroup$ May 10, 2013 at 13:29

2 Answers 2


To understand what is going on lets examine your initial plot. We assign it to the variable g:

g = Show[
       Plot[1/2 x + 1/2, {x, -6, 7}], 
       ListPlot[{{4, -2.5}, {2, 1.5}}, Joined -> True, PlotMarkers -> Automatic]

enter image description here

g // ImageDimensions

{360, 224}

The figure's aspect ratio is therefore:

#2/#1 & @@ ImageDimensions[g] // N


which happens to be close to $\frac{2}{\sqrt{5}+1}\approx 0.6180339887$ or the reciprocal of the golden ratio. This ratio is widely considered as being aesthetically pleasing and is therefore the default aspect ratio for Mathematica's Plot function:

Options[Plot, AspectRatio]

{AspectRatio -> 1/GoldenRatio}

With AspectRatio->Automatic Mathematica sets the aspect ratio to the ratio of the plot ranges in x and y directions:

h = Show[
      Plot[1/2 x + 1/2, {x, -6, 7}], 
      ListPlot[{{4, -2.5}, {2, 1.5}}, Joined -> True, PlotMarkers -> Automatic],     
      AspectRatio -> Automatic

#2/#1 & @@ ImageDimensions[h] // N


#2/#1 & @@ (Subtract @@@ PlotRange[h])


(small difference caused by the discrete pixel size).

This choice causes the the plot space to be isotropic which is needed for a correct display of angles.


enter image description here

Note that the default aspect ratio for Graphics is:

Options[Graphics, AspectRatio]

{AspectRatio -> Automatic}

This makes sense as in most drawings we want an isotropic space.

  • $\begingroup$ Crystal clear answer, I really appreciate it $\endgroup$ Sep 24, 2016 at 16:45

This is really a comment, but it doesn't fit well into a comment box.

Since you say in your profile that you are a fan of minimalism, you might want to consider doing your plot this way:

Plot[1/2 x + 1/2, {x, -6, 7}, 
  Epilog -> Line[{{4, -2.5}, {2, 1.5}}], 
  AspectRatio -> Automatic]

enter image description here

  • $\begingroup$ Sure! That's definitely a better way to do it. $\endgroup$
    – paldepind
    May 19, 2013 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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