Lotta B
Lotta B

Reputation: 115

uneven axis when using pl.imshow

I am having trouble when plotting an image using pylabs imshow. Well there is no problem while plotting but my data is uneven (approx. 32*850) so when I plot it, the y axis is very short compared to the x-axis and you can see an example here example image. I just want the image to be stretched out in the y-axis so it is easier to see.

The code I started with(excluded labels and so on) is:

pl.figure()
pl.imshow(fom_data, interpolation='nearest')
pl.show()

And after googling it I tried changing to

pl.figure(figsize=(6,10))

Which only made the white parts around it larger. I then tried to write it with pyplot instead since it was easier to find people discussing the same thing:

fig, ax = plt.imshow(fom_data,extent=[0,850,0,32],aspect='auto')
plt.show()

As I found in this example: Imshow: extent and aspect but then get the following error message : 'AxesImage' object is not iterable

I am obiusly no pro, but if you know where my brain is going wrong please explain.

Upvotes: 0

Views: 1156

Answers (1)

Julien
Julien

Reputation: 15071

Using pyplot:

plt.figure()
plt.imshow(my_image)
plt.axes().set_aspect(aspect="auto") # grab the current axes to set their aspect

Upvotes: 1

Related Questions