- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I change the font size of ticks of matplotlib.pyplot.colorbar.ColorbarBase?
To change the font size of ticks of a colorbar, we can take the following steps−
- Create a random data set of 5☓5 dimension.
- Display the data as an image, i.e., on a 2D regular raster.
- Create a colorbar with a scalar mappable object image.
- Initialize a variable for fontsize to change the tick size of the colorbar.
- Use axis tick_params() method to set the tick size of the colorbar.
- To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True data = np.random.rand(5, 5) im = plt.imshow(data, interpolation="nearest", cmap="copper") cbar = plt.colorbar(im) tick_font_size = 10 cbar.ax.tick_params(labelsize=tick_font_size) plt.show()
Output
- Related Articles
- How can I change the font size of ticks of axes object in Matplotlib?
- How do I change the font size of the scale in Matplotlib plots?
- How to change the color of the ticks in the colorbar in Matplotlib?
- How to change the font properties of a Matplotlib colorbar label?
- How to add Matplotlib Colorbar Ticks?
- How to change the font size of scientific notation in Matplotlib?
- How do I close all the open pyplot windows (Matplotlib)?
- How do I adjust (offset) the colorbar title in Matplotlib?
- How can I change the font family and font size with jQuery?
- How to change xticks font size in a matplotlib plot?
- How do I change the axis tick font in a Matplotlib plot when rendering using LaTeX?
- How to set the font size of Matplotlib axis Legend?
- How to change the font size of textView in android?
- How to change the font size of Text using FabricJS?
- How to change the spacing between ticks in Matplotlib?

Advertisements