- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 to give Matplolib imshow plot colorbars a label?
To give matplotlib imshow() plot colorbars a label, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create 5×5 data points using Numpy.
Use imshow() method to display the data as an image, i.e., on a 2D regular raster.
Create a colorbar for a ScalarMappable instance, im.
Set colorbar label using set_label() method.
To display the figure, use show() method.
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = np.random.rand(5, 5) im = plt.imshow(data, cmap="copper") cbar = plt.colorbar(im) cbar.set_label("Colorbar") plt.show()
- Top label for Matplotlib colorbars
- How to build colorbars without attached plot in matplotlib?
- How to add a shared x-label and y-label to a plot created with Pandas' plot? (Matplotlib)
- How to plot data into imshow() with custom colormap in Matplotlib?
- Matplotlib – How to set xticks and yticks with imshow plot?
- How to show multiple colorbars in Matplotlib?
- How to plot an emoji as a label for a bar in Matplotlib?
- Can I give a border to a line in Matplotlib plot function?
- How can I plot NaN values as a special color with imshow in Matplotlib?
- How to draw a log-normalized imshow plot with a colorbar representing the raw data in Matplotlib?
- How to add a mathematical expression in axis label in a plot created by using plot function in R?
- How to plot an image with non-linear Y-axis with Matplotlib using imshow?
- How to label bubble chart/scatter plot with column from Pandas dataframe?
- How do you just show the text label in a plot legend in Matplotlib?
- How to add legend to imshow() in Matplotlib?