In [23]:
import numpy as np
import pandas as pd
from IPython.core.display import HTML

import bokeh
print('Bokeh version:', bokeh.__version__)


Bokeh version: 0.12.13

In [24]:
df = pd.read_csv('stress_strain_data.csv', sep=',', header=None, skiprows=0)
df.columns = ['strain', 'stress']
df.head()


Out[24]:
strain stress
0 0.000000 0.000
1 0.000605 43.821
2 0.001211 74.356
3 0.001816 104.930
4 0.002421 137.510

Plot with holoviews and bokeh


In [25]:
import holoviews as hv
hv.extension('bokeh')
import bokeh
print('holovies version: ', hv.__version__)
print('bokeh version, ', bokeh.__version__)


holovies version:  1.9.2
bokeh version,  0.12.13

In [26]:
hv.archive.auto()
scatter = hv.Curve(df, 'strain', 'stress')
scatter


Automatic capture is now enabled. [2017-12-21 17:02:44]
Out[26]:

In [27]:
type(scatter)


Out[27]:
holoviews.element.chart.Curve

In [28]:
hv.archive.export()


Export name: 'bokeh_plot'
Directory    '/home/tribilium/Documents/staticsite/content/code/tensiletest'

If no output appears, please check holoviews.archive.last_export_status()

In [29]:
from IPython.core.display import HTML
HTML('/home/tribilium/Documents/staticsite/content/code/tensiletest/indx.html')


Out[29]:
/home/tribilium/Documents/staticsite/content/code/tensiletest/indx.html

In [30]:
from bokeh.plotting import figure, output_file, show
from bokeh.models import ColumnDataSource, CDSView, IndexFilter
from bokeh.layouts import gridplot

output_file("index_filter.html")

source = ColumnDataSource(data=dict(x=[1, 2, 3, 4, 5], y=[1, 2, 3, 4, 5]))
view = CDSView(source=source, filters=[IndexFilter([0, 2, 4])])

tools = ["box_select", "hover", "reset"]
p = figure(plot_height=300, plot_width=300, tools=tools)
p.circle(x="x", y="y", size=10, hover_color="red", source=source)

p_filtered = figure(plot_height=300, plot_width=300, tools=tools)
p_filtered.circle(x="x", y="y", size=10, hover_color="red", source=source, view=view)

show(gridplot([[p, p_filtered]]))


INFO:bokeh.io.state:Session output file 'index_filter.html' already exists, will be overwritten.

In [31]:
from IPython.core.display import HTML
HTML('index_filter.html')


Out[31]:
Bokeh Plot

In [ ]: