记录学习笔记,供自己学习!
python绘图共享双轴代码:柱状图+折线图
df = pd.read_excel('./1.xlsx',sheet_name = 'Sheet1')
df1 = pd.read_excel('./1.xlsx',sheet_name = 'Sheet2')
fig = plt.figure()
ax1 = fig.add_subplot(111)
#fig, ax1 = plt.subplots()
ax1 = sns.barplot(x="Year",
y="value",
hue='class',
data=df)
ax1.set_xlabel("Year")
ax1.set_ylabel("value")
ax2 = ax1.twinx()
ax2 = ax1.twiny()
ax2.plot(df1['Year'],df1['value1'],'-rs')
plt.show()