Issue
I was wondering if there is a function call that can give me the name of all colormaps available in matplotlib?
It used to be possible by something along the lines of (see here):
import matplotlib.pyplot as plt
cmaps = sorted(m for m in plt.cm.datad if not m.endswith("_r"))
But running this in mpl 1.5 does not return the new colormaps, such as viridis
, magma
and so on. On the new reference page the code actually hardcodes the names (see here) but I was wondering if a similar query to the above is still possible?
Solution
plt.colormaps()
returns a list of all registered colormaps. From the docs:
matplotlib.pyplot.colormaps()
Matplotlib provides a number of colormaps, and others can be added using register_cmap(). This function documents the built-in colormaps, and will also return a list of all registered colormaps if called.
The list this returns includes viridis
, magma
, inferno
and plasma
for me in 1.5.0
Answered By - tmdavison
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.