python画图渐变颜色的代号_Matplotlib中的渐变色绘图

我正在编写一个python应用程序,它从无线传感器网络收集温度和时间。在

简而言之,我的代码片段如下:a.set_facecolor((0.9, 0.9, 1.0))

myFmt = mdates.DateFormatter('%H:%M')

a.xaxis.set_major_formatter(myFmt)

a.xaxis_date()

a.set_title('WSN temperature')

a.set_ylabel('Temp ' + u"\u2103")

a.set_xlabel('Time')

a.grid(True)

a.set_ylim([-20, 40]) #values found in the collectsensor.py

a.yaxis.set_ticks(np.arange(-20, 40, 5))

a.set_xlim([timeIntervalLeft, timeIntervalRight])

cmap = clr.LinearSegmentedColormap.from_list("", ["darkblue", "blue", "violet", "yellow", "orange", "red"])

cmap2 = clr.LinearSegmentedColormap.from_list("", ["red", "orange", "yellow", "violet", "blue", "darkblue"])

a.scatter(timeList, tempList, c=tempList, s=100, cmap=cmap)

y = tempList

s = pd.Series(y, index=timeList)

# convert dates to numbers first

inxval = mdates.date2num(s.index.to_pydatetime())

points = np.array([inxval, s.values]).T.reshape(-1, 1, 2)

segments = np.concatenate([points[:-1], points[1:]], axis=1)

lc = LineCollection(segments, cmap=cmap2, linewidth=3)

lc.set_array(inxval)

a.add_collection(lc)

有了这个代码,我得到了类似于:

k7MmC.png

你可以看到,散射可以利用cmap,因此随着y值的增加,点变得“更热”。我找了一些类似的绘图功能,但我没有找到任何可以为我工作。在

但这里的颜色与y轴上的温度没有真正的关系,而是沿着所有cmap颜色分布。在

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值