Tutorial

Bar Plots

Vertical Bar Plot

Draw a set of vertical bar plots grouped by a categorical variable:

1
2
3
4
5
6
7
8
 import iSeaborn as isn
 from bokeh.plotting import output_file, save

 tips = isn.load_dataset("tips")
 fig = isn.barplot(x="day", y="total_bill", data=tips)

 output_file("verticalBarPlot.html")
 save(fig)
Bokeh Plot

Choose from Interactive Tools

Choose the required interactive tools for visualization by passing value to tools options. Default tools are “pan,box_select,wheel_zoom,box_zoom,reset,save”

1
2
3
4
5
6
7
8
import iSeaborn as isn
from bokeh.plotting import output_file, save

tips = isn.load_dataset("tips")
fig = isn.barplot(x="day", y="total_bill", data=tips, tools="pan, save")

output_file("chooseInteractiveTools.html")
save(fig)
Bokeh Plot

Control Plot Orders

Control bar order by passing an explicit order:

1
2
3
4
5
6
7
8
import iSeaborn as isn
from bokeh.plotting import output_file, save

tips = isn.load_dataset("tips")
fig = isn.barplot(x="time", y="tip", data=tips,order=["Lunch", "Dinner"])

output_file("chooseInteractiveTools.html")
save(fig)
Bokeh Plot

Draw Horizontal Bar

Draw a set of horizontal bars automatically with change of axis.

1
2
3
4
5
6
7
8
import iSeaborn as isn
from bokeh.plotting import output_file, save

tips = isn.load_dataset("tips")
fig = isn.barplot(x="tip", y="day", data=tips)

output_file("drawHorizontalBar.html")
save(fig)
Bokeh Plot

Set Desired Estimator

For example, use median as the estimate of central tendency

1
2
3
4
5
6
7
8
9
import iSeaborn as isn
from bokeh.plotting import output_file, save
from numpy import median

tips = isn.load_dataset("tips")
fig = isn.barplot(x="day", y="tip", data=tips, estimator=median)

output_file("setDesiredEstimator.html")
save(fig)
Bokeh Plot

Choose From Color Palettes

Use a different color palette for the bars:

1
2
3
4
5
6
7
8
import iSeaborn as isn
from bokeh.plotting import output_file, save

tips = isn.load_dataset("tips")
fig = isn.barplot(x= "day", y="total_bill", data=tips, palette="Blues_d")

output_file("chooseFromColorPalletes.html")
save(fig)
Bokeh Plot

Set Specific Color

Plot all bars in a single color:

1
2
3
4
5
6
7
8
import iSeaborn as isn
from bokeh.plotting import output_file, save

tips = isn.load_dataset("tips")
fig = isn.barplot(x= "day", y="total_bill", data=tips, color="salmon")

output_file("setPrefferedColor.html")
save(fig)
Bokeh Plot

Use Hue for Visualization

Draw a set of vertical bars with nested grouping by a two variables:

Note

Click the legend text to view only a selected category.

1
2
3
4
5
6
7
8
import iSeaborn as isn
from bokeh.plotting import output_file, save

tips = isn.load_dataset("tips")
fig = isn.barplot(x="day", y="total_bill", hue="sex", data=tips)

output_file("useHue.html")
save(fig)
Bokeh Plot

Change Plot Properties

Change different plot properties:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import iSeaborn as isn
from bokeh.plotting import output_file, save

tips = isn.load_dataset("tips")
fig = isn.barplot(x="day", y="total_bill", data=tips,
                  plot_width=600, plot_height=200,
                  plot_title="Awesome Plot Title")

output_file("setPlotProps.html")
save(fig)
Bokeh Plot

And More

Change the other aesthetics of the plot as key word arguments as available in bokeh.plotting.figure.vbar , such as changing alpha of the plot.

1
2
3
4
5
6
7
8
import iSeaborn as isn
from bokeh.plotting import output_file, save

tips = isn.load_dataset("tips")
fig = isn.barplot(x="day", y="total_bill", data=tips, alpha=0.3)

output_file("vbarProps.html")
save(fig)
Bokeh Plot