Alter font-size of colorbar tick-labels

I’m plotting a hist2d and a colorbar along with it, like so:

IM = AXES.hist2d(...)
FIG.colorbar(IM[3], ax=AXES)

How do I control the font-size of the labels of the ticks on the color-bar?

This is the only relevant discussion I could find, but how do I do that for a hist2d?

A colorbar is a colorbar so that advice applies to your colorbar. Just return the cbar object when you call fig.colorbar

Well, that post talks about a colorbar axis. How do I extract that from a colorbar object? Because this doesn’t work:

CBAR = FIG.colorbar(IM[3], ax=AXES)
CBAR.tick_params(labelsize=8)

It says:

AttributeError: 'Colorbar' object has no attribute 'tick_params'

From our docs: https://matplotlib.org/gallery/ticks_and_spines/colorbar_tick_labelling_demo.html

1 Like