From: Nikolaus R. <Nik...@ra...> - 2010-07-30 19:34:47
|
Hi, Consider this: X = np.linspace(0.70, 1.1, 100) Y = np.linspace(-1.19, 1.19, 70) (Xs, Ys) = np.meshgrid(X, Y) Z = np.sqrt((Xs-0.9)**2 + Ys**2) - 0.10 fig = plt.figure() ax = fig.add_subplot(111) ax.contour(X, Y, Z) fig.show() This works, but gives the y axis a different scale than the x axis so the ellipses look like circles. How can I get the same scale for the x- and y-axis? I tried to set ax.set_autoscale_on(False), but that resulted in a totally different part of the coordinate system being shown. Thanks, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C |
From: Ryan M. <rm...@gm...> - 2010-07-30 19:46:32
|
On Jul 30, 2010, at 14:34, Nikolaus Rath <Nik...@ra...> wrote: > Hi, > > Consider this: > > X = np.linspace(0.70, 1.1, 100) > Y = np.linspace(-1.19, 1.19, 70) > (Xs, Ys) = np.meshgrid(X, Y) > Z = np.sqrt((Xs-0.9)**2 + Ys**2) - 0.10 > fig = plt.figure() > ax = fig.add_subplot(111) > ax.contour(X, Y, Z) > fig.show() > > This works, but gives the y axis a different scale than the x axis so > the ellipses look like circles. > > How can I get the same scale for the x- and y-axis? > > I tried to set ax.set_autoscale_on(False), but that resulted in a > totally different part of the coordinate system being Try: ax.set_aspect('equal') Ryan |
From: Nikolaus R. <Nik...@ra...> - 2010-07-31 01:06:28
|
Ryan May <rma...@pu...> writes: > On Jul 30, 2010, at 14:34, Nikolaus Rath <Nik...@pu...> wrote: > >> Hi, >> >> Consider this: >> >> X = np.linspace(0.70, 1.1, 100) >> Y = np.linspace(-1.19, 1.19, 70) >> (Xs, Ys) = np.meshgrid(X, Y) >> Z = np.sqrt((Xs-0.9)**2 + Ys**2) - 0.10 >> fig = plt.figure() >> ax = fig.add_subplot(111) >> ax.contour(X, Y, Z) >> fig.show() >> >> This works, but gives the y axis a different scale than the x axis so >> the ellipses look like circles. >> >> How can I get the same scale for the x- and y-axis? >> >> I tried to set ax.set_autoscale_on(False), but that resulted in a >> totally different part of the coordinate system being > > Try: > > ax.set_aspect('equal') Works perfectly, thanks! -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C |