Created
April 22, 2016 23:48
-
-
Save quasiben/d69710874bd150755e6427e66635aad5 to your computer and use it in GitHub Desktop.
sorted bokeh bar plot
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 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) |
Author
quasiben
commented
Apr 22, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment