【发布时间】:2020-12-31 12:36:47
【问题描述】:
从图片中可以看出,此图表中的线从 2 开始,而不是 1。谁能帮我解决这个问题?我应该改变什么让它从 1 开始?
from numpy.random import randint
df1=pd.DataFrame([[1,2,3,4,5,6,7,8,9,10,11],list(randint(400,500,11)),randint(400,500,11)]).T
df1.columns=['CustomerS','value1','value2']
df1=df1.set_index('CustomerS')
df2=pd.DataFrame([[1,2,3,4,5,6,7,8,9,10,11],randint(0,10,11)]).T
df2.columns=['CustomerS','value1']
df2=df2.set_index('CustomerS')
ax=df1.plot(kind='bar',stacked=True)
ax2=ax.twinx()
df2.plot(kind='line', color='r',ax= ax2)
【问题讨论】:
-
你解决了吗?
-
@Grayrigel 不,还没有:(
-
我已经添加了一个答案。如果有帮助,请点赞并采纳。
标签: python pandas matplotlib plot jupyter-notebook