调整matplotlib.axes.axes对象的打印范围,使原点与给定位置对齐
mpl-axes-aligner的Python项目详细描述
概述
matplotlib axes aligner(mpl_axes_aligner)包包含调整matplotlib.axes.Axes对象绘图范围以对齐其原点的模块。
- mpl_axes_aligner.align调整两个matplotlib轴的绘图范围,使其原点与给定位置对齐。
用法
import numpy as np import matplotlib.pyplot as plt import mpl_axes_aligner x = np.arange(0.0, 30, 0.1) y1 = 0.1 * x * np.sin(x) y2 = 0.001*x**3 - 0.03*x**2 + 0.12*x fig = plt.figure() ax1 = fig.add_subplot(111) ax2 = ax1.twinx() ax1.plot(x, y1, color='blue', label='Plot 1') ax2.plot(x, y2, color='red', label='Plot 2') # Align y = 0 of ax1 and ax2 with the center of figure. mpl_axes_aligner.align.yaxes(ax1, 0, ax2, 0, 0.5) plt.show()
要求
- python==2.7、3.4、3.5、3.6
- matplotlib==2.2,3.0
python 3.7可能是可用的,但它没有被选中。