Matplotlib cursor value with two axes

前端 未结 2 1234
陌清茗
陌清茗 2020-12-30 10:44

I used twinx() to get two y-axes on the plot. However, I\'d like the navigation bar to report the y-coordinates of the first axis. It seems by default, it rep

2条回答
  •  太阳男子
    2020-12-30 10:56

    The navigation bar shows the coordinates of the Axes that is on top. Hence, all you have to do is to make the zorder of the right Axes lower than that of the left Axes:

    ax2.set_zorder(-100)
    

    This will also change the appearance of the Figure. That is, everything plotted on the right Axes will go behind everything plotted on the left Axes. In many cases this makes very little or no difference.

提交回复
热议问题