本文介绍了在plt.cm.get_cmap中可以使用什么名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码:

plt.scatter(data_projected[:,0],data_projected[:,1],c=digits.target
        ,edgecolors='none',alpha=0.5,cmap=plt.cm.get_cmap('nipy_spectral',10));    

我的困惑来自 plt.cm.get_cmap('nipy_spectral',10).有时会有 plt.cm.get_cmap('RdYlBu').

My confusion comes from plt.cm.get_cmap('nipy_spectral',10). Sometimes there will be plt.cm.get_cmap('RdYlBu') instead.

'RdYlBu''nipy_spectral'是颜色的名称吗?还有其他名称可以代替吗?

Is the 'RdYlBu','nipy_spectral' the name of a color? And is there any other names to use instead?

是否有所有可用颜色的列表?

Is there a list of all colors available?

我已阅读文档,但它似乎无济于事或我听不懂它.

I have read the document but it does not seem to help or I do not understand it.

推荐答案

plt.cm.get_cmap('nipy_spectral',10)的第一个参数是色图的名称.您可以通过

The first argument to plt.cm.get_cmap('nipy_spectral',10) is the name of a colormap. You can get a list of all available colormaps via

import matplotlib.cm
print(matplotlib.cm.cmap_d.keys())

,或者您可以查看颜色图参考.

这篇关于在plt.cm.get_cmap中可以使用什么名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 18:09