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

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.