Pandas- Data Visualization-Line Chart
Pandas- Data Visualization-Line Chart
Matplotlib: Visualization with Python. Matplotlib is a comprehensive library for creating static, animated, and
interactive visualizations in Python. Matplotlib makes easy things easy and hard things possible. Use
interactive figures that can zoom, pan, update. Pyplot module in Matplotlib supports graph and plots such as
Histogram, Bar Chart etc.
Type of charts
In [ ]:
In [ ]:
In [ ]:
A histogram shows the frequency on the vertical axis and the horizontal axis is
another dimension.
Usually it has bins, where every bin has a minimum and maximum value.
Each bin also has a frequency between x and infinite.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [7]:
Out[7]:
[<matplotlib.lines.Line2D at 0x2675213ef88>]
In [11]:
In [ ]:
In [9]:
Class=['Seven','Eight','Nine','Ten','Eleven','Twelve']
number=[34,56,78,12,67,45]
Age=[13,14,15,16,17,18]
plt.plot(Class,number)
plt.plot(Class,Age)
plt.ylabel('Age/No. of students')
plt.xlabel('Class')
plt.title('No. of student age wise in class')
plt.grid(True)
plt.plot(Class,number,label="Class & no. of students", marker='<',linestyle=':',linewid
th=3,markersize=10,markeredgecolor="blue",color='green',markerfacecolor='red')
plt.plot(Class,Age, label="Class & Age", marker='o',linestyle='--',linewidth=3,markersi
ze=10,color='yellow',markerfacecolor='blue',markeredgecolor='red')
plt.legend()
plt.show()
In [2]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
name=["Sony","Zee","Aaj tak","Star Plus"]
trp=[67,78,89,60]
plt.plot(name,trp,label="Name/TRP of the channels",color="red",linestyle=":")
plt.grid(True)
plt.title("TRP of various Channels",color="red")
plt.xlabel("Name of the channels",fontsize=10,color="red")
plt.ylabel("TRP of the channels",fontsize=10,color="green")
plt.legend()
plt.show()
In [4]:
import matplotlib.pyplot as p
x=[6,7,8,9,10]
y=[60,40,55,30,70]
p.plot(x,y, linestyle="dashed")
p.title('Secondary Class Strength')
p.grid(True)
p.xlabel('Class')
p.ylabel('No. of students')
p.show()
In [ ]: