W3docs

Matplotlib make tick labels font size smaller

Here is a code snippet that shows how to make the tick labels font size smaller in Matplotlib:

Here is a code snippet that shows how to make the tick labels font size smaller in Matplotlib:

make the tick labels font size smaller in Matplotlib

import matplotlib.pyplot as plt

# Create a plot
fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4])

# Make tick labels font size smaller
ax.tick_params(axis='both', which='major', labelsize=6)

plt.show()

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Python - The Practical Guide</div>

You can adjust the font size by changing the value passed to the labelsize parameter. In this example, the tick labels font size is set to 6.