将两个图合并为一个图

时间:2021-02-17 05:56:27

标签: python scatter-plot overlap errorbar

我使用以下代码绘制了两个图形。我的问题是我无法将它们合并在一个图中,它们将显示为 2 个重叠图。我的数据来自 Excel 文件。

values = df [['H', 'D', 'sdD']]
ax1 = values.plot.scatter (x = 'H', y = 'D', yerr = 'sdD',s = 50, color = 'blue', label = 'D', figsize = (10,6))
plt.ylabel('Crater Diameter')
plt.xlabel('Total Drop Height')

plt.xscale("log")
plt.yscale("log")

plt.savefig('kineticsand_errorbars.png')

values2 = df [['H', 'Dm']]
ax2 = values2.plot(x = 'H', y = 'Dm',lw = 1, color = 'red', label ='Dm = 0.5018H^0.2790', figsize = (10,6))
plt.ylabel('Crater Diameter')
plt.xlabel('Total Drop Height')

plt.xscale("log")
plt.yscale("log")

plt.savefig('kineticsand_model.png')

plt.legend()
fig.show()
plt.show()

0 个答案:

没有答案