python - Plotting not rounded values in matplotlib with imshow -
i plotting numpy array matplotlib (imshow function). size 1000*3000 , values floats between 0 , around 2000.
when maximum values around 10 (it test) have correct values on figure, amplitude, values rounded int cannot see nuance in part of array.
is there parameter in imshow corresponding problem ? thought second (cmap=none) didn't succeed.
here example :
import numpy np import matplotlib.pyplot plt import random rand data = np.zeros((10,10)) in range(10): j in range(10): data[i,j] = 900 + 10*i + rand.random() plt.imshow(data) plt.show()
the values in matplotlib window integer whereas in real array not.
you can modify coordinate formatter. official example shown here. also, first part of answer this question shows different way of doing same thing. have modified code x , y coordinates integers while z float 4 decimal places:
class formatter(object): def __init__(self, im): self.im = im def __call__(self, x, y): z = self.im.get_array()[int(y), int(x)] return 'x=%i, y=%i, z=%1.4f' % (x, y, z) data = np.zeros((10, 10)) in range(10): j in range(10): data[i, j] = 900 + 10 * + rand.random() fig, ax = plt.subplots() im = ax.imshow(data) ax.format_coord = formatter(im) plt.show()
Comments
Post a Comment