Search code examples
pythonmatplotlibhistogramaxis-labelslogarithm

How to remove ticklabels on a histogram with log scale


The following code does not remove yticklabels while it should since there is ax.set_yticklabels([]).

import numpy as np
import matplotlib.pyplot as plt

data = np.random.standard_normal(10)

fig = plt.figure()

ax = plt.axes()

ax.hist(data)
ax.set_yscale('log')

ax.set_yticklabels([])

enter image description here

Note: if changing 10 by 100 in data = np.random.standard_normal(10), the yticklabels are correctly removed... enter image description here

  • Is this a bug to report? If so, how (and where) to report it?

  • Is there another way to remove those yticklabels?

Many thanks for your help!


Solution

  • you can hide like below:

    ax.axes.get_xaxis().set_visible(False)
    ax.axes.get_yaxis().set_visible(False)