python - Matplotlib imshow: cursor coordinates fail when ticks are specified -


when use imshow plot image in bottom right corner of window coordinates of cursor show up. when try set ticks , tick labels of axes window stops displaying coordinates , displays "x= y="

minimal example:

import matplotlib.pyplot plt import numpy np  d = np.random.rand(100, 100)  fig = plt.figure() ax = plt.gca() plt.imshow(d)  # if comment coordinates in bottom right, # after setting ticks "x= y=" ax.set_xticks([0, 25, 50, 75, 100]) ax.set_xticklabels([0, 0.25, 0.5, 0.75, 1]) ax.set_yticks([0, 25, 50, 75, 100]) ax.set_yticklabels([0, 0.25, 0.5, 0.75, 1])  fig.show() raw_input() 

this displays random map of data , sets tick labels 0 1, cursor coordinates in bottom right shows "x= y=".

is there way coordinates show in new units defined ticks? think has setting transform axes can't figure out.

you should use "extent" argument when calling "imshow":

import matplotlib.pyplot plt import numpy np  d = np.random.rand(100, 100)  fig = plt.figure() ax = plt.gca() plt.imshow(d, extent=(0,1,1,0))  ax.set_xticks([0, 0.25, 0.50, 0.75, 1]) ax.set_yticks([0, 0.25, 0.50, 0.75, 1])  fig.show() raw_input() 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -