【发布时间】:2017-04-04 21:30:32
【问题描述】:
我有一个简单的 pandas 数据框,我想用 matplotlib 进行绘图:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_excel('SAT_data.xlsx', index_col = 'State')
plt.figure()
plt.scatter(df['Year'], df['Reading'], c = 'blue', s = 25)
plt.scatter(df['Year'], df['Math'], c = 'orange', s = 25)
plt.scatter(df['Year'], df['Writing'], c = 'red', s = 25)
这是我的情节的样子:
我想将蓝色数据点向左移动一点,将红色数据点向右移动一点,因此 x 轴上的每一年都有三个小列的散点数据,而不是全部三个数据集重叠。我尝试并未能正确使用“verts”参数。有没有更好的方法来做到这一点?
【问题讨论】:
标签: python pandas matplotlib