Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make unit interval on both axes to have equal lengths visually in Mathematica

I want to make a plot in which unit interval on both axes to have equal lengths visually. i.e. I want (1,1) and (0,0) to make a square rather than an elongated rectangle.

I could not find the option to make it possible for the following simple case:

ListLinePlot[{{{0, 0}, {1, -1}, {2, -2}, {3, -1}, {4, -2}, {5, -3}, {6, -4}, {7, -3}, {8, -2}, {9, -1}}}]

Thank you for your help.

Edit

More generally, how to adjust the ratio of the unit interval on x-axis to that on y-axis? AspectRatio option does not seem to directly correlate with it.

like image 693
Qiang Li Avatar asked Jun 09 '11 18:06

Qiang Li


1 Answers

You want: AspectRatio -> Automatic.


Example of the requested generalization:

p = Plot[Sin[x], {x, 0, 10}];
range = First /@ Differences /@ (PlotRange /. Options[p]);
target = 1/2;(* 1 y == 2 x *)
Show[p, 
 AspectRatio -> (Last[range]/First[range]/target)]

(Plot by default will include an explicit plot range, so we can use Options, as long as we don't set something like PlotRange->All.)

like image 89
Brett Champion Avatar answered Oct 18 '22 13:10

Brett Champion