Sebagian besar utilitas Matplotlib terletak di bawah submodul pyplot, dan biasanya diimport di sebagai plt:
format perintah nya :
import matplotlib.pyplot as plt
Sekarang paket Pyplot dapat disebut sebagai plt.
Contoh:
Gambar garis dalam diagram dari posisi (5,20) ke posisi (10,300):
Tulis program dibawah ini dan Run, hasilnya adalah grafik garis linear dilayar komputer
import matplotlib.pyplot as plt
import numpy as np
xpoints = np.array([5, 20])
ypoints = np.array([10, 300])
plt.plot(xpoints, ypoints)
plt.show()
Apabila program diatas dijalankan , hasilnya seperti gambar dibawah.
C:\Windows\system32>python
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> xpoints=np.array([5,20])
>>> ypoints=np.array([10,300])
>>> plt.plot(xpoints,ypoints)
[<matplotlib.lines.Line2D object at 0x000001D64DF87240>]
>>> plt.show()
0 Response to "Matplotlib Pyplot"
Post a Comment