python:matplotlib 绘制两条y轴

    技术2022-07-11  107

    实例代码

    x= np.arange(10) y1 = x**2 y2 = x**4 _,ax=plt.subplots() ax.plot(x,y1,'b') ax.set_xlabel('x') ax.set_ylabel('y1',color='b') ax2 = ax.twinx() ax2.plot(x,y2,'r') ax2.set_ylabel('y2',color='r')

    结果

    Processed: 0.011, SQL: 9