Python 在matplotlib中找不到rainbow方法
我正在使用Python 在matplotlib中找不到rainbow方法,python,matplotlib,Python,Matplotlib,我正在使用matplotlib2.2.3下面是我的代码 import matplotlib.pyplot as plt """Plot out the different clusters""" # Choose a different colour for each cluster colour = plt.cm.rainbow(np.linspace(0, 1, len(centroids))) 它将抛出无法找到rainbowreference这是matplotlib的问题,它不是num
matplotlib
2.2.3下面是我的代码
import matplotlib.pyplot as plt
"""Plot out the different clusters"""
# Choose a different colour for each cluster
colour = plt.cm.rainbow(np.linspace(0, 1, len(centroids)))
它将抛出无法找到
rainbow
reference这是matplotlib
的问题,它不是numpy
。你能检查一下你正在使用的matplotlib
吗?试试plt.get\u cmap('rainbow')
。matplotlib 2.2.3肯定在pyplot中提供了matplotlib.cm
,因此plt.cm.rainbow
将可用。如果它对您不起作用,可能是您无意中覆盖了某些内容。