Pandas DataFrame Plot boxplot graph

Pandas plot

Pandas.DataFrame.plot to generate boxplot using data

Box plot display summary of five that is minimum, first quartile, median, third quartile and maximum.
The box is drawn between first and third quartile.
Median is drawn within the box.
Let us try one example. Here we have sample data for two subjects. DataFrame boxplot
import pandas as pd 
my_dict={
'MATH':[30,33,32,32,31,34,32],
'ENG':[32,31,35,34,35,34,32]    
}
df = pd.DataFrame(data=my_dict)
df.boxplot(figsize=(5,3),grid=True)

boxplot with options

There are several options we can add to above boxplot.

return_type

Default type is 'axis', we can set it to return_type='dict' , return_type='axes' or return_type='both'.

grid

We will show grid ( grid=True ) or not ( grid=False) grid=True option grid=False option






df.boxplot(grid=False,figsize=(5,3))

figsize :

Size of the graph , it is a tuple saying width and height in inches, figsize=(6,3). Here width is 6 inches and height is 3 inches.
df.boxplot(figsize=(5,3))

rot

rot=45 Rotation of x axis labels in degree.
Rotation of ticks ( check the names at x axis )
rot=45 rot=180







df.boxplot(figsize=(5,3),rot=180)

fontsize

fontsize=20 , we can set the font size used labels in x and y axis. fontsize=20
df.boxplot(figsize=(5,3),fontsize=20)



Pandas plot plot.barh()


plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer