如题。
Matlab中,执行一次plot后,用语句hold on
然后再plot,两次画图即在一张图上。
在Python中,matplotlib.pyplot或者更多程序包,怎样实现?
多次plot,在同一张图上?
怪我咯2017-04-17 14:55:06
matplotlib is almost the same as Matlab, and does not require a hold on statement. For example
import matplotlib.pyplot as plt
x = range(10)
y1 = [elem*2 for elem in x]
plt.plot(x, y1)
y2 = [elem**2 for elem in x]
plt.plot(x, y2, 'r--')
plt.show()