Reputation: 33
I am trying to make a color map in Matplotlib so that I could pass it in plt.get_cmap()
. Based on tutorials, I only see making color maps via RGB levels. But I have three (3) hex codes that I want to use in my chart. These are: #f1a340
, #f7f7f7
, and #998ec3
.
Anybody experienced making a color map using Hex Codes?
Thank you :)
Upvotes: 1
Views: 7246
Reputation: 45
I would recommend converting your hex values into RGB tuples, then adding them all to a list. you can then utilize the from_list() method of linearSegmentedColormap to create a unique color map
LinearSegmentedColormap.from_list()
If you need more information you can use this as a reference:
https://matplotlib.org/gallery/images_contours_and_fields/custom_cmap.html
Upvotes: 1