Examples
import numpy as np
import pandas as pd
df = pd.DataFrame({'lab':['P', 'Q', 'R'], 'val':[20, 40, 30]})
ax = df.plot.barh(x='lab', y='val')
Plot a whole DataFrame to a horizontal bar plot:
speed = [0.1, 20.5, 50, 68, 72, 89, 98]
lifespan = [2, 10, 70, 5.5, 35, 22, 38]
index = ['snail', 'goat', 'elephant',
'dog', 'cat', 'fox', 'horse']
df = pd.DataFrame({'speed': speed,
'lifespan': lifespan}, index=index)
ax = df.plot.barh()
Plot a column of the DataFrame to a horizontal bar plot
speed = [0.1, 20.5, 50, 68, 72, 89, 98]
lifespan = [2, 10, 70, 5.5, 35, 22, 38]
index = ['snail', 'goat', 'elephant',
'dog', 'cat', 'fox', 'horse']
df = pd.DataFrame({'speed': speed,
'lifespan': lifespan}, index=index)
ax = df.plot.barh(y='speed')
Plot DataFrame versus the desired column:
speed = [0.1, 20.5, 50, 68, 72, 89, 98]
lifespan = [2, 10, 70, 5.5, 35, 22, 38]
index = ['snail', 'goat', 'elephant',
'dog', 'cat', 'fox', 'horse']
df = pd.DataFrame({'speed': speed,
'lifespan': lifespan}, index=index)
ax = df.plot.barh(x='lifespan')