bokeh 3rd: high-level charts

Where to get Bokeh high-level charts that can be simply created through pandas DataFrame?

bokeh high-level charts

advantages

  • high-level charts can use DataFrame directly
  • can choose colors automatically based on groups in the data. pass (color='categorical data column')
  • For drawing different markers automatically based on groups in the data.

Histograms

  • from bokeh.charts import Histogram
  • Histogram(df, 'column name',...)
In [1]:
from bokeh.charts import Histogram,output_file, output_notebook, show
from bokeh.sampledata.iris import flowers as df
# bokeh.io
from bokeh.plotting import figure
In [2]:
output_notebook()
Loading BokehJS ...
In [3]:
df.head(0)
Out[3]:
sepal_length sepal_width petal_length petal_width species
In [4]:
# figure(plot_width=400,plot_height=400)
p=Histogram(df, 'petal_length',title='Iris Morphology',\
           plot_width=500,plot_height=400,\
           bins=25, color='silver')
show(p)

group by categories map to color

In [5]:
p=Histogram(df, values='petal_length',title='Iris Morphology',\
           plot_width=600,plot_height=400,\
           bins=5, color='species',legend='top_right')
# p.legend.location='bottom_right'
p.yaxis.axis_label='test,test,test'
show(p)

Boxplots

  • box and whiskers
  • from bokeh.charts import BoxPlot
    • label='column you want to group'
      • label are the groups
        • Boxplots(df, values='', label='',color='', ...)
          • pass cat data to color
In [6]:
from bokeh.charts import BoxPlot
p=BoxPlot(df, values='petal_length',title='BoxPlot',\
           plot_width=600,plot_height=400, color='species',\
           label='species',legend='bottom_right')

p.yaxis.axis_label='This is a y label'

show(p)

scatter

two-dimensional data

diff marker & diff color

In [7]:
from bokeh.charts import Scatter
In [8]:
p=Scatter(df, x='petal_length',y='sepal_length',
         title='Iris what is Scatter', color='species', marker = 'species',
         plot_width=600,plot_height=400)
show(p)
In [ ]:
 

Leave a Reply

Your email address will not be published.

Notice: Undefined index: cookies in /var/www/html/wp-content/plugins/live-composer-page-builder/modules/tp-comments-form/module.php on line 1638