<jupyter_start><jupyter_text>Colorbar Tick Labelling DemoProduce custom labelling for a colorbar.Contributed by <NAME><jupyter_code>import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm
from numpy.random import randn<jupyter_output><empty_output><jupyter_text>Make plot with vertical (default) colorbar<jupyter_code>fig, ax = plt.subplots()

data = np.clip(randn(250, 250), -1, 1)

cax = ax.imshow(data, interpolation='nearest', cmap=cm.coolwarm)
ax.set_title('Gaussian noise with vertical colorbar')

# Add colorbar, make sure to specify tick locations to match desired ticklabels
cbar = fig.colorbar(cax, ticks=[-1, 0, 1])
cbar.ax.set_yticklabels(['< -1', '0', '> 1'])  # vertically oriented colorbar<jupyter_output><empty_output><jupyter_text>Make plot with horizontal colorbar<jupyter_code>fig, ax = plt.subplots()

data = np.clip(randn(250, 250), -1, 1)

cax = ax.imshow(data, interpolation='nearest', cmap=cm.afmhot)
ax.set_title('Gaussian noise with horizontal colorbar')

cbar = fig.colorbar(cax, ticks=[-1, 0, 1], orientation='horizontal')
cbar.ax.set_xticklabels(['Low', 'Medium', 'High'])  # horizontal colorbar

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13395113732097724, 'fraction_numerical': 0.02106149957877001, 'mean_word_length': 6.973154362416107, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '540731', 'license': 'MIT', 'n_tokens_mistral': 451, 'n_tokens_neox': 421, 'n_words': 103, 'path': 'matplotlib/gallery_jupyter/ticks_and_spines/colorbar_tick_labelling_demo.ipynb', 'repo_name': 'kingreatwill/penter', 'size': '1195'}