« Pandas plot
Pandas.DataFrame.plot to generate hexbin using data
import pandas as pd
import numpy as np
n = 10000
df=pd.DataFrame({'x': np.random.randn(n),
'y': np.random.randn(n)})
ax=df.plot.hexbin(x='x',y='y',gridsize=20)
hexbin chart with options
There are several options we can add to above hexbin diagram.
title :
title='hexbin Plot' String used as Title of the graph.
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.plot.hexbin(x='x',y='y',gridsize=20,figsize=(6,3))
fontsize
fontsize=20 , we can set the font size used labels in x and y axis.
df.plot.hexbin(x='x',y='y',gridsize=20,fontsize=20)
color
We can use the option colors to give different colors to line . We can use one tuple to define the colours.
df.plot.hexbin(x='x',y='y',gridsize=20,title='hexbin Plot',color=[(.9,.2,.6)])
grid
We will show grid ( grid=True ) or not ( grid=False)
df.plot.hexbin(x='x',y='y',gridsize=20,title='grid=True',grid=True)
logx logy loglog
We can specify log scaling or symlog scaling for x ( logx=True ) or y ( logy=True ) or for both x & y ( loglog=True)
df.plot.hexbin(x='x',y='y',gridsize=20,title='loglog=True',loglog=True)
« Pandas plot
plot.barh()
← Subscribe to our YouTube Channel here