Remove axis ticks but keep grid using Matplolib / ggplot style
You can declare a color for ticks. In this case a transparent one:
from matplotlib import pyplot as plt
import numpy
data = numpy.random.randint(0, 100, size=(100,100))
plt.style.use('ggplot')
fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(111)
ax.imshow(data)
ax.tick_params(axis='x', colors=(0,0,0,0))
ax.tick_params(axis='y', colors=(0,0,0,0))
plt.show()
, which results in:
from matplotlib import pyplot as plt
import numpy
data = numpy.random.randint(0, 100, size=(100,100))
plt.style.use('ggplot')
fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(111)
plt.imshow(data)
ax.grid(True)
for axi in (ax.xaxis, ax.yaxis):
for tic in axi.get_major_ticks():
tic.tick1On = tic.tick2On = False
tic.label1On = tic.label2On = False
plt.show()
plt.savefig('noticks.pdf', format='pdf', bbox_inches='tight')
plt.close()