Skip to content

Instantly share code, notes, and snippets.

@quasiben
Created April 22, 2016 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quasiben/d69710874bd150755e6427e66635aad5 to your computer and use it in GitHub Desktop.
Save quasiben/d69710874bd150755e6427e66635aad5 to your computer and use it in GitHub Desktop.
sorted bokeh bar plot
import pandas as pd
import numpy as np
from bokeh.plotting import figure, output_file, show
from bokeh.charts import Bar
from bokeh.charts.attributes import ColorAttr, CatAttr
from bokeh.charts.builders.bar_builder import BarBuilder
output_file('try_select.html')
df = pd.DataFrame(np.random.randint(0,100,size=(100, 2)), columns=['other_values', 'values'])
df.sort_values('values', inplace=True)
df.reset_index(inplace=True)
df.rename(columns={'index': 'fields'}, inplace=True)
plt = Bar(df, values='values', label=CatAttr(columns=['fields'], sort=False),)
show(plt)
@quasiben
Copy link
Author

screen shot 2016-04-22 at 4 48 17 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment