图例中只有一部分显示在多轴图中

时间:2019-02-24 18:28:18

标签: python jupyter-notebook jupyter

我正在处理一个带有两个y轴和三个图的图(两个图共享相同的x和y轴。仅显示两个图例(对于等式8和等式5),由于某种原因,没有显示全部三个图例。 v2和v3之前是通过冗长的计算定义的 这是我的代码和图表:

fig, ax = plt.subplots()
ax.set_xlabel('Percent glycerol in the mixture')
ax.set_ylabel('Eq 4 and Eq 5')
ax.plot(x, y, '-r', label='Eq 4')
ax.plot(x,y2, '-b', label='Eq 5')
ax.grid()
ax2 = ax.twinx()
ax2.set_ylabel('Eq 8')
ax2.plot(x, y3, '-g', label='Eq 8')
ax2.legend(loc=0)
ax3 = ax2
color = 'tab:red'
ax3.errorbar(75, 29.45, 0.2, fmt='o')

fig.tight_layout()
plt.show()`

graph with multiple axes

0 个答案:

没有答案