Pandas DataFrame Plot hexbin graph

Pandas plot

Pandas.DataFrame.plot to generate hexbin using data
DataFrame hexbin chart
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 :

figsize=(6,3)
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. fontsize=20
df.plot.hexbin(x='x',y='y',gridsize=20,fontsize=20)

color

color option for hexbin diagram 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) grid=True option grid=False option






df.plot.hexbin(x='x',y='y',gridsize=20,title='grid=True',grid=True)

logx logy loglog

option logy=True 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


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





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