Python | Colorbar Label

In this tutorial, we are going to learn how to add a colour-bar label using matplotlib.pyplot.colorbar)?
Submitted by Anuj Singh, on August 05, 2020

matplotlib.pyplot.colorbar(label='Colorbar**')

Following figure shows the implementation of the same in a scatter plot.

Illustration:

Python colorbar label

Python code for colorbar label

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(50)
y = np.random.randint(0,50,50)
ss = np.random.randint(0,50,50)
c = np.random.randint(0,50,50)

plt.figure()
plt.scatter(x,y, s=ss*10, c=c)
plt.title('Scatter Plot Example')
plt.colorbar(label='Color Map : Inferno')
plt.show()

Output:

Output is as figure


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.