Getting Started with Matplotlib.
Matplotlib is a visulization library in python.Matplotlib is a comprehensive library for creating static, animated,graphs and interactive visualizations in Python. Matplotlib makes easy things easy and hard things possible.This library built on the numpy library.
Matplotlib consists of several plots like line, bar, scatter, histogram etc.
Matplotlib and its dependencies are available for macOS, Windows and Linux distributions we can install them by :
python -m pip install -U matplotlib
for importing matplotlib package use the command :
import matplotlib.pyplot as plt
Matplotlib graphs your data on Figure
s (e.g., windows, Jupyter widgets, etc.), each of which can contain one or more Axes
, an area where points can be specified in terms of x-y coordinates.
By using pyp.plot() function we can plot a simple graph EX,
Draw a line from (0 , 5) to (0,100)
import matplotlib.pyplot as plt
import numpy as np
x_points = np.array([0,5])
y_points = np.array([0,100])
plt.plot(x_points, y_points)
plt.show()
plt.savefig(‘first.png’)
just like another we are plotting some points:
plt.plot([1,2,3,4])
plt.show()
Plotting points :
import matplotlib.pyplot as plt
import numpy as np x = np.array([1,2,3,4])
y = np.array([10,8,9,7])plt.plot(x,y)
plt.show()#for bar
# plt.bar(x,y)
For more refer the document: