为什么matplotlib在jupyter notbook中显示的绘图与导出到pd时不同

2024-06-28 19:07:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在我的jupyter笔记本中绘制一个图形,如下所示:

fig3, ax3 = plt.subplots()

color = 'tab:red'
ax3.set_xlabel('active learning cycles')
ax3.set_ylabel('amount', color=color)
ax3.plot(al_cycle_count, al_bbs_count, color=color)
ax3.plot(al_cycle_count, ccs, color=color, dashes=[6, 2])
ax3.tick_params(axis='y', labelcolor=color)

ax4 = ax3.twinx()  # instantiate a second axes that shares the same x-axis

ax4.set_ylabel('% (1 = 100%)')
ax4.plot(al_cycle_count, precisions)
ax4.plot(al_cycle_count, recalls)
ax4.plot(al_cycle_count, f1s)

ax3.set(title='performance of "' + experiment_name + '"')
fig3.legend(['Bounding Boxen', 'Learning Steps', 'Precision', 'Recall', 'F1'], loc='upper right', bbox_to_anchor=(0.35, 0.9))

#fig3.tight_layout()  # otherwise the right y-label is slightly clipped
plt.show()

输出如下所示:

enter image description here

一旦我保存了.fig的情节,传奇就被压缩到情节中,名字也被删掉了(我知道这显然太长了)

enter image description here

我能以某种方式控制保存的情节吗?如何更好地放置图例而不隐藏情节信息


Tags: therightplotcountpltcoloralset