【发布时间】:2020-04-13 09:49:46
【问题描述】:
我有一个 pandas 数据框,我需要从中绘制带有标记的线图。为此,我将数据框转换为index= "Distance", columns= "system", values= "fscore" 的数据透视表。使用下面代码 sn-p 中使用的plot 方法,我可以获得如下所示的线图。但是,如何根据lenth 列中的值(或lenth 列中值的标准化分数)来改变标记大小?
代码sn-p:
plotPD = df.pivot(index="Distance", columns="system", values="fscore").fillna(0)
ax = plotPD.plot(
marker="H",
title="plotTitle",
xticks=(range(0, len(plotPD.index) + 2, 2)),
yticks=np.arange(0, 1.1, 0.1),
)
ax.set_xlabel(plotPD.index.name, fontsize=14)
原始数据框distPD
system Distance lenth summ fscore
0 L2S 12 45 31 0.688889
1 L2S 9 84 52 0.619048
2 L2S 1 1685 1471 0.872997
3 L2S 2 578 403 0.697232
4 L2S 13 47 30 0.638298
279 BiAFF 17 9 8 0.888889
280 BiAFF 19 7 5 0.714286
281 BiAFF 21 5 5 1.000000
282 BiAFF 20 4 4 1.000000
283 BiAFF 26 2 2 1.000000
【问题讨论】:
标签: python pandas matplotlib pivot-table