python - 2D Map in matplotlib with discrete values -
i'm trying plot matplotlib 2d map recorded instrument. instrument moving 2 motors (it makes raster) , records associated intensity value. i'm able plot data , associate values want axes, digitize (make discrete) these values in order obtain @ each pixel of image corresponding values motors.
i'm using following code (in example i'll use x , y define motor positions):
import pylab pl pl.imshow(intensity, extent=(x_min, x_max, y_min, y_max), interpolation='none')
the code works quite if select 1 of pixel on plot cursor, returns continuous values many digits (like in figure).
would possible obtain directly values of motors (which have stored each point/pixel) positioning cursor on them?
thanks help,
fabio
you can modifying coordinate formatter in this example on matplotlib documentation. simple adaptation request is:
import numpy np import matplotlib.pyplot plt import matplotlib.cm cm x = 10*np.random.rand(5, 3) fig, ax = plt.subplots() ax.imshow(x, cmap=cm.jet, interpolation='nearest') def format_coord(x, y): return 'x=%i, y=%i' % (x+1, y+1) ax.format_coord = format_coord plt.show()
, result in this:
also might want check out mpldatacursor more pretty. option take @ this question here in so.
Comments
Post a Comment