1 year ago
#361629

FreeToGo
How to list all the ScalarMapple colormaps in Matplotlib?
Whenever I do interpolation plot, I noted that not every colormap in Matplotlib.cm is ScalarMappable. I wonder what is the proper way to get the full list of colormap which is ScalarMappable?
I manage to get the full list by reading the trackback message as following. But I don't think it is a good idea.
def get_scmaps():
try:
from traceback import format_exc
plt.cm.ScalarMappable(cmap="xyz")
except ValueError:
result = format_exc()
search_str = "supported values are "
if search_str in result:
smaps = (result.split(search_str)[-1])[1:-1].split("', '")
return smaps
matplotlib
colormap
scalar
0 Answers
Your Answer