 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Extract Matplotlib colormap in hex-format
To extract matplotlib colormap in hex-format, we can take the following steps −
- Get the rainbow color map. 
- Iterate in the range of rainbow colormap length. 
- Using rgb2hex method, convert rgba tuple to a hexadecimal representation of a color. 
Example
from matplotlib import cm import matplotlib cmap = cm.rainbow for i in range(cmap.N):    rgba = cmap(i)    print("Hexadecimal representation of rgba:{} is {}".format(rgba, matplotlib.colors.rgb2hex(rgba)))  Output
............... ........................ .................................... Hexadecimal representation of rgba:(1.0, 0.3954512068705424, 0.2018824091570102, 1.0) is #ff6533 Hexadecimal representation of rgba:(1.0, 0.38410574917192575, 0.1958454670071669, 1.0) is #ff6232 Hexadecimal representation of rgba:(1.0, 0.37270199199091436, 0.18980109344182594, 1.0) is #ff5f30 .........................................................
Advertisements
 