python - matplotlib 中的 zorder 与共享 x_axis 没有放在首位
问题描述
这是我的代码,输出图:
fig, ax1 = plt.subplots()
color = 'tab:red'
ax1.set_xlabel('Iterations')
ax1.set_ylabel('Non metric loss', color=color)
ax1.plot(net_loss_bigger, color=color, zorder=3)
ax1.tick_params(axis='y', labelcolor=color)
ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis
color = 'tab:blue'
ax2.set_ylabel('metric supervised loss', color=color) # we already handled the x-label with ax1
ax2.plot(metric_super_loss_bigger, color=color, zorder=2)
ax2.tick_params(axis='y', labelcolor=color)
解决方案
推荐阅读
- python - 检查 value 是否变为 1 并保持为 1
- python - 从.h5文件加载权重时出现Tensorflow 2.0 ValueError
- macos - Interface Builder 和 NSTableView 顶部约束
- javafx - 是否存在不会显示 javaFX 场景中的节点的情况?
- python - 每日数据抓取
- node.js - 使 req 对象可用于每个视图文件
- python - 如何解决 django.template.exceptions.TemplateSyntaxError
- c++ - VS2019 linux找不到额外的依赖
- python - Python在json文件中的字典中打开具有相同名称的新文件
- kubernetes - IAP 连接器未将请求路由到本地。“没有健康的上游”