Data Visualization avec Bokeh
Data
Charts
1. Table
2. Barplot
source = ColumnDataSource(data)
barplot = figure(plot_width=800,
plot_height=400,
x_range=items,
title="A simple bar chart")
barplot.vbar(x="item",
bottom=0,
top="size",
color='gray',
width=0.7,
source=source)
barplot.xaxis.major_label_orientation = 1
barplot.xgrid.grid_line_color = None
barplot.y_range.start = 0
show(barplot)
3. Pie Chart
data = pd.DataFrame({"item": items, "size": sizes})
data = data.sort_values(by="size")
data['percent'] = data['size']/data['size'].sum() * 100
data['percent'] = data['percent'].apply(lambda x: str(round(x, 2))+'%')
data['angle'] = data['size']/data['size'].sum() * 2*3.14
data['color'] = ['gray' for i in range(len(data))]
source = ColumnDataSource(data)
pie = figure(plot_width=500,
height=500,
x_range=(-1, 1),
title="A simple bar chart")
pie.annular_wedge(x=0,
y=1,
inner_radius=0.5,
outer_radius=0.8,
start_angle=cumsum('angle',include_zero=True),
end_angle=cumsum('angle'),
color='color',
alpha=0.7,
source=source)
pie.axis.axis_label = None
pie.axis.visible = False
pie.grid.grid_line_color = None
show(pie)
4. Line plot
6. Scatterplot