For most types of plots drawn by Matplotlib, the ticks and labels along both X and Y axis is drawn too. To hide the ticks, labels or axis, we need to get the axes of the currently generated plot and change its properties.

To hide the axis of a plot:

import matplotlib.pyplot as mplot
# After creating plot ...
cur_axes = mplot.gca()
cur_axes.axes.get_xaxis().set_visible(False)
cur_axes.axes.get_yaxis().set_visible(False)

To hide only the ticks of a plot:

import matplotlib.pyplot as mplot
# After creating plot ...
cur_axes = mplot.gca()
cur_axes.axes.get_xaxis().set_ticks([])
cur_axes.axes.get_yaxis().set_ticks([])

To hide only the labels of the ticks of a plot:

import matplotlib.pyplot as mplot
# After creating plot ...
cur_axes = mplot.gca()
cur_axes.axes.get_xaxis().set_ticklabels([])
cur_axes.axes.get_yaxis().set_ticklabels([])

Thank you.

LikeLike