Skip to content

Commit 9dfc100

Browse files
committed
wip: initial silly plots
1 parent 534108e commit 9dfc100

File tree

6 files changed

+112
-8
lines changed

6 files changed

+112
-8
lines changed

.github/workflows/deploy.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@ jobs:
3434
- uses: actions/setup-node@v4
3535
with:
3636
node-version: 18.x
37+
- uses: actions/setup-python@v5
38+
with:
39+
python-version: '3.12'
40+
cache: 'pip' # caching pip dependencies
41+
- name; Install Python dependencies
42+
run: pip install -r requirements.txt
3743
- name: Install MyST Markdown
3844
run: npm install -g mystmd
3945
- name: Build HTML Assets
40-
run: myst build --html
46+
run: myst build --html --execute
4147
- name: Upload artifact
4248
uses: actions/upload-pages-artifact@v3
4349
with:

bokeh.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
kernelspec:
3+
name: python3
4+
display_name: Python 3
5+
---
6+
7+
# Bokeh
8+
9+
```{code-cell} python3
10+
import numpy as np
11+
from scipy.integrate import odeint
12+
13+
from bokeh.plotting import figure, show
14+
from bokeh.io import output_notebook
15+
16+
output_notebook()
17+
```
18+
19+
```{code-cell} python3
20+
:name: fig-bokeh
21+
22+
sigma = 10
23+
rho = 28
24+
beta = 8.0/3
25+
theta = 3 * np.pi / 4
26+
27+
def lorenz(xyz, t):
28+
x, y, z = xyz
29+
x_dot = sigma * (y - x)
30+
y_dot = x * rho - x * z - y
31+
z_dot = x * y - beta* z
32+
return [x_dot, y_dot, z_dot]
33+
34+
initial = (-10, -7, 35)
35+
t = np.arange(0, 100, 0.006)
36+
37+
solution = odeint(lorenz, initial, t)
38+
39+
x = solution[:, 0]
40+
y = solution[:, 1]
41+
z = solution[:, 2]
42+
xprime = np.cos(theta) * x - np.sin(theta) * y
43+
44+
colors = ["#C6DBEF", "#9ECAE1", "#6BAED6", "#4292C6", "#2171B5", "#08519C", "#08306B"]
45+
46+
p = figure(title="Lorenz attractor example", background_fill_color="#fafafa")
47+
48+
p.multi_line(np.array_split(xprime, 7), np.array_split(z, 7),
49+
line_color=colors, line_alpha=0.8, line_width=1.5)
50+
51+
show(p)
52+
```

index.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# The Basics
1+
# Plots
22

3-
## This is a Heading
3+
There are many plots, such as [](#fig-plotly-output) and [](#fig-bokeh-output). See them below!
44

5-
Style Sheets can target families of HTML elements like `h2`:
6-
:::{literalinclude} style.css
7-
:start-after: BEGIN-H2
8-
:end-before: END-H2
5+
:::{embed} #fig-plotly
6+
:remove-input: true
7+
8+
A plotly figure.
99
:::
1010

11-
The `!important` here is required to override the more-specific CSS selectors from our theme.
11+
![](#fig-bokeh)

myst.yml

+2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ project:
66
references:
77
guide: https://mystmd.org/guide
88
toc:
9+
- file: index.md
910
- file: bokeh.md
11+
- file: plotly.md
1012
site:
1113
template: book-theme
1214
options:

plotly.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
kernelspec:
3+
name: python3
4+
display_name: Python 3
5+
---
6+
7+
# Plotly
8+
9+
```{code-cell} python3
10+
import plotly.graph_objects as go
11+
import numpy as np
12+
13+
np.random.seed(1)
14+
```
15+
16+
```{code-cell} python3
17+
#| label: fig-plotly
18+
19+
# Number of data points
20+
N = 10000
21+
22+
# Generate random data
23+
x = np.random.randn(N)
24+
y = np.random.randn(N).astype('float32')
25+
z = np.random.randint(size=N, low=0, high=256, dtype='uint8')
26+
c = np.random.randint(size=N, low=-10, high=10, dtype='int8')
27+
28+
fig = go.Figure(data=[go.Scatter3d(
29+
x=x,
30+
y=y,
31+
z=z,
32+
marker=dict(color=c),
33+
mode='markers',
34+
opacity=0.2
35+
)])
36+
37+
fig.show()
38+
```

requirements.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
scipy
2+
numpy
3+
plotly
4+
bokeh
5+
jupyter-server
6+
ipykernel

0 commit comments

Comments
 (0)