我有一个dataframe (df)和两个系列,我已经从那个dataframe切片了。
例如,X是2014-10 - 2014-11 Y是类似123,345,678的数字,我想要这样的图形:
700
*
500
300
*
100 *
2014-10 2014-11 2014-12我的代码:
xlist = df.month #series
x_string = str(xlist) #string
ylist = df.numbers #series
y_string = str(ylist) #string
plt.xticks(x,x_string) #set to use my series as the x axis values
plt.plot(x, ylist, 'bo') #plot x(x_string) and y(ylist) axis on the graph.
plt.show() #show my graph我试过绘制这个系列和字符串,但都没有用。
现在有人建议我不要使用xticks,我可以得到:
df.plot(x='month',
y='numbers',
title='Time dependency of ...')发布于 2014-11-28 00:37:57
你可以做这个直接在熊猫身上
df.plot(x='month', y='numbers', title='Time dependency of ...')或者:
df[['month', 'numbers']].set_index('month').plot(title='Time dependency of ...')这是假设df是一个包含“月份”和“数字”列的数据框架。
https://stackoverflow.com/questions/27180423
复制相似问题