【发布时间】:2021-06-02 22:11:28
【问题描述】:
我在 matplotlib 图形的左侧和右侧使用两个 y 轴进行绘图,并使用 zorder 来控制绘图的位置。我需要在同一图中定义zorder across 轴。
问题
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-10,10,0.01)
fig, ax1 = plt.subplots( 1, 1, figsize=(9,3) )
ax1.plot( x, np.sin(x), color='red', linewidth=10, zorder=1 )
ax2 = ax1.twinx()
ax2.plot( x, x, color='blue', linewidth=10, zorder=-1)
在上图中,我希望蓝线出现在红色图的后面。
使用双轴时如何控制zorder?
我正在使用:
python:3.4.3 + numpy:1.11.0 + matplotlib:1.5.1
【问题讨论】:
标签: python numpy matplotlib