2024-04-26 10:36:53 发布
网友
我的数据框看起来:
我用这个代码画出来:
tmp['event_name'].plot(style='.', figsize=(20,10), grid=True)
结果显示:
我想更改点的大小(使用列细节)。 问题: 我该怎么做?绘图没有参数大小,我不能使用绘图.散点()因为我不能对x轴使用时间格式。在
你可以这样做:
for index, i in enumerate(df['details']): plt.plot(df.index[index], df.iloc[index]['event_name'], marker='.', linestyle='None', markersize=i*4, color='b') plt.show()
示例:
数据框:
details event_name time 2015-01-01 46 2 2015-01-02 16 2 2015-01-03 1 2 2015-01-04 7 2 2015-01-05 4 2
输出:
^{}将所有未知关键字传递给Matplotlib.Artist,如链接文档中所述。因此,可以使用一般matplotlib语法ms指定标记大小:
Matplotlib.Artist
ms
tmp['event_name'].plot(style='.', figsize=(20,10), grid=True, ms=5)
也就是说,您也可以将plt.scatter与时间戳一起使用,这使得使用'details'列作为标记大小更加直接:
plt.scatter
你可以这样做:
示例:
^{pr2}$数据框:
输出:
^{} 将所有未知关键字传递给
Matplotlib.Artist
,如链接文档中所述。因此,可以使用一般matplotlib语法ms
指定标记大小:也就是说,您也可以将
^{pr2}$plt.scatter
与时间戳一起使用,这使得使用'details'列作为标记大小更加直接:相关问题 更多 >
编程相关推荐