I wanted to plot using imshow in a manner similar to the second example here http://www.scipy.org/Plotting_Tutorial but to redefine the scale for the axis. I'd also like the image to stay still while I do this!
The code from the example:
from scipy import *
from pylab import *
# Creating the grid of coordinates x,y
x,y = ogrid[-1.:1.:.01, -1.:1.:.01]
z = 3*y*(3*x**2-y**2)/4 + .5*cos(6*pi * sqrt(x**2 +y**2) + arctan2(x,y))
hold(True)
# Creating image
imshow(z, origin='lower', extent=[-1,1,-1,1])
xlabel('x')
ylabel('y')
title('A spiral !')
# Adding a line plot slicing the z matrix just for fun.
plot(x[:], z[50, :])
show()
If I modify the extent to be wider, eg:
imshow(z, origin='lower', extent=[-4,4,-1,1])
Then the resulting image is stretched. But all I wanted to do was change the ticks to coincide with my data. I know I can use pcolor to conserve the X and Y data, though that has other ramifications to it.
I found this answer which allows me to manually redo all the ticks:
How do I convert (or scale) axis values and redefine the tick frequency in matplotlib?
But that seems a bit overkill.
Is there a way to only change the extent shown by the labels?