Pandas 用于说明分数前后的绘图类型

Pandas 用于说明分数前后的绘图类型,pandas,matplotlib,plot,graph,charts,Pandas,Matplotlib,Plot,Graph,Charts,给定这样的基本数据集: import pandas as pd df = pd.DataFrame([ {'sid': 'SID0', 'before': .5, 'after': .8}, {'sid': 'SID1', 'before': .6, 'after': .4}, {'sid': 'SID2', 'before': .2, 'after': .2} ]); # `before `has max value of 1.0; same for `after`, as th

给定这样的基本数据集:

import pandas as pd

df = pd.DataFrame([
  {'sid': 'SID0', 'before': .5, 'after': .8},
  {'sid': 'SID1', 'before': .6, 'after': .4},
  {'sid': 'SID2', 'before': .2, 'after': .2}
]);
# `before `has max value of 1.0; same for `after`, as these are percentages

用什么方法来绘制前后分数的差异


考虑排除SID,并正确显示分布情况(学生的情况很重要;而不仅仅是分散绘制分数)。对于SID,我使用了斜率图,但这不利于显示聚合反射。

IIUC,类似于以下内容(Chainsmokers/Coldplay):


方案:您可以为每个SID绘制一个线图

import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame([
  {'sid': 'SID0', 'before': .5, 'after': .8},
  {'sid': 'SID1', 'before': .6, 'after': .4},
  {'sid': 'SID2', 'before': .2, 'after': .2}
]);

df = df.set_index("sid")[['before', "after"]].T

ax = df.plot(marker="o")
ax.set_xlim(-1,2)
ax.set_xticks([0,1])
ax.set_xticklabels(df.index)

plt.show()

你在策划什么?@cᴏʟᴅsᴘᴇᴇᴅ - 我认为这是问题的一部分。这与时间或类似的事情无关。我想直观地展示学生考试成绩之间的改善/损害(差异);没有策划任何小岛屿发展中国家也许一个条形图或一个点图的每个点都有一个半径,半径与得分的人数有关;前/后的颜色不同。
import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame([
  {'sid': 'SID0', 'before': .5, 'after': .8},
  {'sid': 'SID1', 'before': .6, 'after': .4},
  {'sid': 'SID2', 'before': .2, 'after': .2}
]);

df = df.set_index("sid")[['before', "after"]].T

ax = df.plot(marker="o")
ax.set_xlim(-1,2)
ax.set_xticks([0,1])
ax.set_xticklabels(df.index)

plt.show()