How to change tick label font size
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In Matplotlib, tick label font size is controlled separately from axis titles, legends, and figure titles. The cleanest answer is usually tick_params, but there are a few related patterns depending on whether you want to style one axis, both axes, or all plots globally.
The Most Direct Method: tick_params
For one axes object, this is usually the best solution.
axis="both" changes both x and y tick labels. You can target only one axis with axis="x" or axis="y".
Change X and Y Separately
If you want different font sizes on each axis, set them independently.
That is useful when one axis contains dense categories and the other needs stronger emphasis.
Style Existing Tick Labels Directly
You can also modify the tick label text objects themselves.
This approach is more verbose but gives you per-label control when needed.
Set a Global Default
If you want all figures in a script or notebook to use the same tick label size, update rcParams.
That is useful for reports or dashboards where consistent styling matters across many plots.
Tick Labels Versus Axis Labels
The pyplot Shortcut
If you are working in a quick script without keeping an Axes reference, plt.xticks and plt.yticks can also change tick label size. It is less explicit than ax.tick_params, but it is common in short notebook examples.
A common source of confusion is mixing up tick labels with axis labels.
- tick labels are the numbers or categories along the axis
- axis labels are the descriptive titles such as “Time” or “Revenue”
Axis labels are changed separately.
Changing axis-label font size does not affect tick-label font size.
Layout Matters Too
Larger tick labels can overlap or get clipped. If you increase font size, you may also need to adjust layout.
This is especially important in notebooks, saved figures, or rotated category labels.
Common Pitfalls
The most common mistake is changing axis-label font size and expecting tick labels to change with it.
Another mistake is setting large tick fonts without adjusting layout, which often leads to clipped text or overlapping labels.
Developers also sometimes use global rcParams for a one-off figure and then wonder why later plots inherit the same styling unexpectedly.
Summary
- Use
ax.tick_params(labelsize=...)for the simplest per-plot solution. - You can style x and y tick labels separately.
- Use direct label objects only when you need fine-grained control.
- Use
rcParamsfor global defaults across many plots. - Bigger tick labels often require layout adjustments such as
tight_layout().
If category labels are long, you may also need to rotate them so the larger font remains readable. Small typography changes often require a matching spacing change in the figure.

