'ListedColormap'类型的对象没有len()

时间:2018-07-28 16:29:05

标签: python matplotlib

我正在尝试修改本文中的代码

Python scatter plot. Size and style of the marker

给出不同的颜色图。我尝试过

import circlesDrawer as cdraw
import matplotlib as mpl
from pylab import *
figure(figsize=(6,4))
ax = subplot(aspect='equal')
cmap = mpl.colors.ListedColormap(['royalblue', 'cyan',
                                  'yellow', 'orange'])
#plot a set of circle
a = [1,2,3]
x = [1,3,4]
y = [1,3,2]

out=cdraw.circles(x,y,1,c=a,alpha=0.5,fc=cmap)
colorbar()

show()

但收到错误

object of type 'ListedColormap' has no len()
  

我不知道如何解决这个问题。

1 个答案:

答案 0 :(得分:1)

您使用了错误的参数来提供颜色表。我想应该是

Uri

假设,其他所有设置都正确。