import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax2 =ax1.twinx()
x = np.array([1,2,3,4,5,6,7,8])
y = np.array([3,5,7,6,2,6,10,15])
ax1.plot(x,y,'r')# 折线 1 x 2 y 3 color
ax2.plot(x,y*y,'g',lw=1)# 4 line w
print(plt.show())
网友评论