Created
November 21, 2018 19:50
-
-
Save josellausas/9df34297a55bc6fe5bfe63534ad9a38c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path | |
import pandas as pd | |
from bokeh.core.properties import value | |
from bokeh.io import show, output_file, output_notebook | |
from bokeh.plotting import figure | |
output_notebook() | |
def plot_state_incidents(data): | |
year_names = [str(x) for x in data['year'].values.tolist()] | |
years = year_names | |
y_axis = ["geom", "no-geo"] # Y (geo, no-geo) | |
colors = ["#c9d9d3", "#e84d60"] | |
data['no-geo'] = data['count'] - data['geom'] | |
parsed = {'years' : years, | |
'geom' : data['geom'], | |
'no-geo': data['no-geo'] | |
} | |
p = figure(x_range=years, plot_height=250, title="Entries by state", | |
toolbar_location=None) | |
p.vbar_stack(y_axis, x='years', width=0.9, color=colors, source=parsed, | |
legend=[value(x) for x in y_axis]) | |
p.y_range.start = 0 | |
p.x_range.range_padding = 0.1 | |
p.xgrid.grid_line_color = None | |
p.axis.minor_tick_line_color = None | |
p.outline_line_color = None | |
p.legend.location = "top_left" | |
p.legend.orientation = "horizontal" | |
show(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment