python plt x轴比例不同于d轴比例

2024-09-26 18:09:15 发布

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

我的数据集如下所示:

     Month  DeviceType  AvgRevenue
0   201608  desktop     3.029642
1   201608  mobile      0.197588
2   201608  tablet      1.575810
3   201609  desktop     2.352156
4   201609  mobile      0.182009

我试着画一个图来可视化它,但是,x轴与原始数据不同,因为我的x轴应该是年和月,图上显示的x轴是不合理的…我如何纠正这个问题?谢谢

fig, ax = plt.subplots()
for name, group in device.groupby('DeviceType'):
    group.plot('Month', y='AvgRevenue', ax=ax, label=name)

enter image description here


Tags: 数据name原始数据可视化groupfigpltmobile

热门问题