x = np.linspace(-2*np.pi, 2*np.pi, 200) y1 = np.square(x) y2 = np.cos(x) fig = plt.figure() ax = fig.add_axes([0.1, 0.1, 0.8, 0.8]) ax_twinx = ax.twinx() ax.plot(x, y1, c='r') ax_twinx.plot(x, y2, c='g', ls='-.') plt.show() 效果如下图所示。
www.jb51.net/python/2956218...htm 2025-2-7