python - “ListedColormap”类型的对象没有 len()
问题描述
我正在尝试修改此帖子中的代码
给出不同的颜色图。我努力了
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()
我不知道如何解决这个问题。
解决方案
您使用了错误的参数来提供您的颜色图。我想应该是
circles(x, y, 1, c=a, alpha=0.5, cmap=cmap)
假设,其他一切都设置正确。
推荐阅读
- drools - Drools - 何时使用多个 kie 会话?
- javascript - mongodb 找不到匹配项
- javascript - 试图为我的机器人制作一个不和谐的歌曲队列
- git - 基于 yaml 管道上的资源的条件
- video-streaming - WebRTC - WebRTC: ICE failed, add a STUN server and see about:webrtc 了解更多详情
- asp.net-mvc - 如何在使用 ASP.NET MVC 的 Plesk 托管中使用 Rotativa 生成 PDF?
- javascript - A4 页面中 Array 的 Angular Splitting Object 它工作起来很奇怪,但并不例外
- xml - 如何在 xslt 中选择名称和相应的内容?
- javascript - 在 laravel 刀片中显示 JSON 数组
- javascript - 无法将值从承诺分配给类的属性