Skip to content

Instantly share code, notes, and snippets.

@Ogaday
Created April 5, 2018 12:12
Show Gist options
  • Save Ogaday/e4bbc9cf2a6f16ab3f1713d4323ce082 to your computer and use it in GitHub Desktop.
Save Ogaday/e4bbc9cf2a6f16ab3f1713d4323ce082 to your computer and use it in GitHub Desktop.
Minimal bokeh-stitch example
FROM continuumio/miniconda3:latest
RUN conda update conda -y
WORKDIR /opt/example/
COPY environment.yml /opt/example/
COPY ex_bokeh.ipymd /opt/example/
COPY run.sh /opt/example/
RUN chmod +x run.sh
RUN conda env create -f environment.yml
CMD ["./run.sh"]
name: bokeh
dependencies:
- python=3.6.5=hc3d631a_0
- bokeh=0.12.15=py36_0
- pypandoc=1.4=py36_0
- jupyter=1.0.0=py36_4
- pip:
- knotr==0.4.1
# Bokeh Integration
> [Bokeh](http://bokeh.pydata.org/en/latest/) is a Python interactive visualization library that targets modern web browsers for presentation.
This document can be compiled to HTML with
```
stitch ex_bokeh.txt -o ex_bokeh.html --no-self-contained
```
The easiest way to use stitch & Bokeh together is with the ``Bokeh.output_notebook``
method.
```{python}
from bokeh.plotting import figure, show, output_notebook
# prepare some data
x = [0.1, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0]
y0 = [i**2 for i in x]
y1 = [10**i for i in x]
y2 = [10**(i**2) for i in x]
output_notebook()
```
```{python}
# create a new plot
p = figure(
tools="pan,box_zoom,reset,save",
y_axis_type="log", y_range=[0.001, 10**11], title="log axis example",
x_axis_label='sections', y_axis_label='particles'
)
# add some renderers
p.line(x, x, legend="y=x")
p.circle(x, x, legend="y=x", fill_color="white", size=8)
p.line(x, y0, legend="y=x^2", line_width=3)
p.line(x, y1, legend="y=10^x", line_color="red")
p.circle(x, y1, legend="y=10^x", fill_color="red", line_color="red", size=6)
p.line(x, y2, legend="y=10^x^2", line_color="orange", line_dash="4 4")
# show the results
show(p)
```
See also Bokeh's tools for [embedding](http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html)
the HTML and javascript necessary to get a figure to show up in HTML output.
. /opt/conda/etc/profile.d/conda.sh;
conda activate bokeh;
stitch ex_bokeh.ipymd -o ex_bokeh.html --no-self-contained;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment