Matplotlib¶
Installation¶
Best to create a virtual environment
$ python -m venv ~/env-for-my-work
$ . ~/env-for-my-work/bin/activate
(env-for-my-work) $
Install via Python Package Index
(env-for-my-work) $ python -m pip install matplotlib
Basic Usage¶
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [i**2 for i in x]
plt.plot(x, y)
plt.ylabel('squares')
plt.show()
Axis Ranges¶
Axis ranges are specified in the form [xmin, xmax, ymin, ymax]
, like so,
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [i**2 for i in x]
plt.plot(x, y)
plt.axis([0, 8, 0, 20])
plt.ylabel('squares')
plt.show()