- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
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 .........................................................
- Related Articles
- How to extract a subset of a colormap as a new colormap in Matplotlib?
- How to set a default colormap in Matplotlib?
- Defining the midpoint of a colormap in Matplotlib
- Defining a discrete colormap for imshow in Matplotlib
- How to make the Parula colormap in Matplotlib?
- Set a colormap of an image in Matplotlib
- How to draw node colormap in NetworkX/Matplotlib?
- Add alpha to an existing Matplotlib colormap
- Matplotlib Plot Lines with Colors through Colormap
- How to increase colormap/linewidth quality in streamplot Matplotlib?
- Plot a histogram with colors taken from colormap in Matplotlib
- 3D scatterplots in Python Matplotlib with hue colormap and legend
- How to display the matrix value and colormap in Matplotlib?
- How to plot data into imshow() with custom colormap in Matplotlib?
- MySQL extract year from date format?

Advertisements