matplotlib制作双Y轴图

2018-11-07  本文已影响0人  tutu_tutu

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())

上一篇下一篇

猜你喜欢

热点阅读