Python 画图:在同一张图上画两次,怎样执行?
PHP中文网
PHP中文网 2017-04-17 14:53:06
0
1
3167

如题。
Matlab中,执行一次plot后,用语句hold on
然后再plot,两次画图即在一张图上。

在Python中,matplotlib.pyplot或者更多程序包,怎样实现?
多次plot,在同一张图上?

PHP中文网
PHP中文网

认证0级讲师

Antworte allen(1)
刘奇

matplotlib 和 Matlab 差不多,而且不需要 hold on 语句。例如

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()
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!