June 2018
Intermediate to advanced
398 pages
9h
English
We will start with simple examples to explore matplotlib's functionality. The first thing we do usually is import matplotlib into our Python script:
import matplotlib.pyplot as plt
Notice we imported pyplot as a short name, plt, to be used inside our script. Now, we will use the plot() method inside it to plot our data, which consists of two lists. The first list represents the values of the x-axis while the second list represents the values of the y-axis:
plt.plot([0, 1, 2, 3, 4], [0, 10, 20, 30, 40])
Now, the values are dropped into the plot.
The last step is to show that plot as a window using the show() method:
plt.show()
Read now
Unlock full access