Python Matplotlib
It is the very provider of the visual library of Python,It creates static ,animated effects.Matplotlibs is a cross platform data visualization library.
Installation of Matploatlib
The following command should be run
python -mpip install -U matplotlib
Matplolib comes with large variety of plots to it help to understand the complex algorithm with the simple graph.lets take some demonstration
Plot Structure : Plot function is used to create or draw the line chart via given the array in this tutorial with the help of a program we have drawn the plot chart.
Program
#importing matplotlib library from matplotlib import pyplot as abc a = [9,8,7,6,5,4,3] #creates array “a” b = [7,3,5,2,6,8,1] #another array “b” abc.plot(a,b) #invoke plot chart abc.show() #call show function
Output
Above program output are plot chart by invoking function plot function, let’s demonstrate a bar chart with similar program.
Bar Chart
Program 2
from matplotlib import pyplot as abc #import matplotlib library as abc a = [9,8,7,6,5,4,3] #two array are define name as “a” and “b” b = [7,3,5,2,6,8,1] abc.bar(a,b) #now invoke bar chart abc.show() #calling show function
Output
By invoking predefined bar chart function above output shown. Let’s take the same program but with a different chart.
Histogram Chart
Program 3
from matplotlib import pyplot as abc a = [9,8,7,6,5,4,3] #define list or array abc.hist(a) #invoking histogram function abc.show() #invoking show function
Output
By invoking histogram chart function above out shown in histogram chart only one value be passed.
Scatter Chart
Program 4
from matplotlib import pyplot as abc #import matplotlib library as abc a = [9,8,7,6,5,4,3] #define one dimensional array b = [7,3,5,2,6,8,1] #define one dimensional array abc.scatter(a,b) #invokes scatter chart function abc.show()
Output
By using scatter chart the following output is mentioned above.