我使用以下代码生成图表:
# Initialize fig & axis objects
fig, ax1 = plt.subplots(1, 1, sharex=True)
# Add second y-axis
ax2=ax1.twinx()
# Create 4 legends
ln0 = ax2.plot([0,100], [80.5, 80.5],color='darkgreen',label='Y_axis-2')
ln1 = ax1.plot([0,100],[79,79], color='darkred', label='Y_axis-1a')
ln2 = ax1.plot([0,100],[80.5,80.5], color='darkorange', label='Y_axis-1b')
ln3 = ax1.plot([0,100],[81,81], color='darkblue', label='Y_axis-1c')
lns = ln0 + ln1 + ln2 + ln3
labs = [l.get_label() for l in lns]
# Add legends to graph
ax1.legend(lns, labs, bbox_to_anchor=(0.65,0.45))
# Label axes
ax1.set_xlabel('X-axis', fontsize=12)
ax1.set_ylabel('Y1-Axis', fontsize=12)
ax2.set_ylabel('Y2-Axis', fontsize=12)
# Make and save plot
plt.title('Title')
plt.tight_layout()
plt.savefig("dummy.png", bbox_inches='tight')
我在我的 jupyter 笔记本中看到以下图像:
但是,当我打开/查看保存的 png 文件时,我看到:
为什么我的标题、轴标签和轴刻度值不显示在白色背景上,而不是深色或中性背景?