3

I am using the labels on axis of an imshow plot as labels for different tests and therefore I want these labels to be real. However I am getting float numbers e.g. 3.5 ,3.0. How can I change this?

Example:

import numpy as np
from matplotlib import pyplot as plt
a=np.random.randn(4,4)
plt.imshow(a,extent=[1,5,1,5],interpolation='none')
plt.show()

enter image description here

Cupitor
  • 11,007
  • 19
  • 65
  • 91
  • 1
    possible duplicate: http://stackoverflow.com/questions/12608788/changing-the-tick-frequency-on-x-or-y-axis-in-matplotlib – fredtantini Nov 27 '14 at 16:23

1 Answers1

2

Just use an integer array to set the ticks:

plt.xticks(np.arange(1, 6, dtype=np.int))
deinonychusaur
  • 7,094
  • 3
  • 30
  • 44