Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slight improvement on the Local Modules subsection #92

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions GETTING-STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,18 @@ number generation steps in a function in the file `data.py`.
```python
# data.py
import numpy as np
import matplotlib.pyplot as plt


def make_x_and_y(n):
x = np.random.randn(n)
y = np.random.randn(n)
return x, y
n = np.arange(n)
return x, y, n


def get_cmap(n, name='hsv'):
return plt.cm.get_cmap(name, n)
```

In the HTML tag `<py-env>` paths to local modules are provided in the
Expand All @@ -186,14 +193,16 @@ In the HTML tag `<py-env>` paths to local modules are provided in the
<div id="plot"></div>
<py-script output="plot">
import matplotlib.pyplot as plt
from data import make_x_and_y
from data import make_x_and_y, get_cmap

x, y = make_x_and_y(n=1000)
x, y, n = make_x_and_y(n=1000)

cmap = get_cmap(len(n))

fig, ax = plt.subplots()
ax.scatter(x, y)
ax.scatter(x, y, c=cmap(n))
fig
</py-script>
</body>
</html>
```
```