在matplotlib上给定类型error之间填充

2024-09-27 21:33:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下数字:

enter image description here

由以下代码生成:

def graph(seconds,now, dayold, threedayold,weekold):
    dis=4*24*60*60
    x = np.array(seconds[-dis:])

    ynow = np.array(now)
    yday = np.array(dayold)
    y3day = np.array(threedayold)
    yweek = np.array(weekold)
    plt.plot(x,ynow, 'blue')
    plt.plot(x,yday, 'green')
    plt.plot(x,y3day,'purple')
    plt.plot(x,yweek, 'red')
#   plt.fill_between(x,ynow,yday,color='lightblue')
#   plt.fill_between(x,yday,y3day,color='green')
#   plt.fill_between(x,y3day,yweek,color='purple')
#   plt.fill_between(x,yweek,[0] *len(seconds),color='red')
    currenttime=int(seconds[0])
    lastweek=myround(currenttime-7*24*3600)
    plt.xlim(lastweek, currenttime)
    plt.ylim(ymax=100)
    ticks=np.arange(lastweek,currenttime,24*3600)
    labels=[time.strftime("%a", time.gmtime(x)) for x in ticks]
    plt.xticks(ticks,labels)
    plt.grid()
    plt.savefig('/home/joereddington/joereddington.com/stress/stress.png')

但我想要的是一个更像这样的数字:

enter image description here

在我的本地计算机上,当前被注释掉的行可以实现这一点,但是,当我在服务器上尝试它们时,我得到:

^{pr2}$

我做错什么了。。。更重要的是,我该如何修复它?在


Tags: plotnppltbetweenarrayfillcolorseconds
1条回答
网友
1楼 · 发布于 2024-09-27 21:33:52

传入的数据既不是numpy数组也不是列表,调用np.array无法将原始数据转换为numpy数组。在

举个例子,试试看

foo = set(['aa',1,2,3])
print(array(foo).__repr__())

打印array(set(['aa', 1, 2, 3]), dtype=object)

相关问题 更多 >

    热门问题