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).

example_map

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:

changing format of mouse position in matplotlib window

also might want check out mpldatacursor more pretty. option take @ this question here in so.


Comments

Popular posts from this blog

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

javascript - Laravel datatable invalid JSON response -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -