from bokeh.sampledata.autompg import autompg as df
from bokeh.sampledata.olympics2014 import data
from bokeh.sampledata.iris import flowers
from bokeh.charts import Scatter, output_notebook, show
from bokeh.charts.operations import blend
from bokeh.charts.utils import df_from_json
import pandas as pd
output_notebook()
scatter0 = Scatter(
df, x='mpg', title="x='mpg'", xlabel="Miles Per Gallon")
show(scatter0)
scatter1 = Scatter(
df, x='mpg', y='hp', title="x='mpg', y='hp'",
xlabel="Miles Per Gallon", ylabel="Horsepower", legend='top_right')
show(scatter1)
scatter2 = Scatter(
df, x='mpg', y='hp', color='cyl', title="x='mpg', y='hp', color='cyl'",
xlabel="Miles Per Gallon", ylabel="Horsepower", legend='top_right')
show(scatter2)
scatter3 = Scatter(
df, x='mpg', y='hp', color='origin', title="x='mpg', y='hp', color='origin'",
xlabel="Miles Per Gallon", ylabel="Horsepower", legend='top_right')
show(scatter3)
scatter4 = Scatter(
df, x='mpg', y='hp', color='cyl', marker='origin', title="x='mpg', y='hp', color='cyl', marker='origin'",
xlabel="Miles Per Gallon", ylabel="Horsepower", legend='top_right')
show(scatter4)
df2 = df_from_json(data)
df2 = df2.sort('total', ascending=False)
df2 = df2.head(10)
df2 = pd.melt(df2, id_vars=['abbr', 'name'])
scatter5 = Scatter(
df2, x='value', y='name', color='variable', title="x='value', y='name', color='variable'",
xlabel="Medals", ylabel="Top 10 Countries", legend='bottom_right')
show(scatter5)
scatter6 = Scatter(flowers, x=blend('petal_length', 'sepal_length', name='length'),
y=blend('petal_width', 'sepal_width', name='width'), color='species',
title='x=petal_length+sepal_length, y=petal_width+sepal_width, color=species',
legend='top_right')
show(scatter6)