先引包
import numpy as np
import matplotlib.pyplot as plt
双坐标轴
x=np.arange(2,20,1)
y1=x*x
y2=np.log(x)
fig=plt.figure()
ax1=fig.add_subplot(111)
ax1.plot(x,y1)
ax1.set_ylabel('Y1')#坐标轴命名
ax2=ax1.twinx()#生成一个双胞胎坐标轴
ax2.plot(x,y2,color='r')
ax2.set_ylabel('Y2')
ax1.set_xlabel('xxx')
plt.show()