I am displaying a jpg image (I rotate this by 90 degrees, if this is relevant) and of course the axes display the pixel coordinates. I would like to convert the axis so that
It looks like you're dealing with the matplotlib.pyplot
interface, which means that you'll be able to bypass most of the dealing with artists, axes, and the like. You can control the values and labels of the tick marks by using the matplotlib.pyplot.xticks command, as follows:
tick_locs = [list of locations where you want your tick marks placed]
tick_lbls = [list of corresponding labels for each of the tick marks]
plt.xticks(tick_locs, tick_lbls)
For your particular example, you'll have to compute what the tick marks are relative to the units (i.e. pixels) of your original plot (since you're using imshow
) - you said you know how to do this, though.
I haven't dealt with images much, but you may be able to use a different plotting method (e.g. pcolor
) that allows you to supply x
and y
information. That may give you a few more options for specifying the units of your image.
For tutorials, you would do well to look through the matplotlib gallery - find something you like, and read the code that produced it. One of the guys in our office recently bought a book on Python visualization - that may be worthwhile looking at.
The way that I generally think of all the various pieces is as follows:
Figure
is a container for all the Axes
Axes
is the space where what you draw (i.e. your plot) actually shows upAxis
is the actual x
and y
axespyplot
module in production plots.