4

How do I combine those statements:

pyplot.axis([1234.0, 1773.0, 497.0, 1362.0])
pyplot.axis('equal')

I just want to define the limits of my axes, but with an equal scale in both directions.

P.S.: I tried pyplot.axis([1234.0, 1773.0, 497.0, 1362.0], 'equal'), but didn't worked.

Matthias
  • 4,481
  • 12
  • 45
  • 84

2 Answers2

4

If you want to define a parameter, but call the parameter list out of order and/or omit some parameters, you need to specify which parameter you are trying to set.

In this case, you want to set aspect so just assign 'equal' to that.

pyplot.axis([1234.0, 1773.0, 497.0, 1362.0], aspect = 'equal')
Cory Kramer
  • 114,268
  • 16
  • 167
  • 218
  • Found out that it still is not the right scale, but I added this now: pyplot.gca().set_aspect('equal', adjustable='box') which works because I used my measuring rod. – Matthias Apr 19 '14 at 11:48
3

The scale still seemed not right with using

pyplot.axis([1234.0, 1773.0, 497.0, 1362.0], aspect = 'equal')

I searched a bit further on StackOverflow and changed my code to:

pyplot.axis([xmin, xmax, ymin, ymax])
pyplot.gca().set_aspect('equal', adjustable='box')

The adjustable='box' was necessary for a question about a 3D plot, but seems also necessary for my 2D plot.

Sources:

2D plot question

3D plot question

Community
  • 1
  • 1
Matthias
  • 4,481
  • 12
  • 45
  • 84