Comparison between categorical data
Bar Plot is one such example. To plot a bar graph using plot() function will be used.
Syntax:
matplotlib.pyplot.plot(\*args, scalex=True, scaley=True, data=None, \*\*kwargs)
Example:
Python3
# importing pandas library import pandas as pd # importing matplotlib library import matplotlib.pyplot as plt # creating dataframe df = pd.DataFrame({ 'Name' : [ 'John' , 'Sammy' , 'Joe' ], 'Age' : [ 45 , 38 , 90 ] }) # plotting a bar graph df.plot(x = "Name" , y = "Age" , kind = "bar" ) |
Output:
How to plot a Pandas Dataframe with Matplotlib?
Prerequisites:
Data visualization is the most important part of any analysis. Matplotlib is an amazing python library which can be used to plot pandas dataframe. There are various ways in which a plot can be generated depending upon the requirement.