# Summary

## Recommendations for longer notebooks

You can do that using Markdown. This produces a nice overview for longer notebooks. Example: https://stackoverflow.com/a/39817243

## Discussion points

Use cases and reproducibility

• If you are already using Jupyter, what tasks do you use it for?

• If you are new to Jupyter, do you see any possible use cases?

• Do you think Jupyter Notebooks can help tackle the problem of irreproducible results?

Are Jupyter notebooks “workflows”?

• A reproducible workflow documents a “pipeline”

• Also a Jupyter notebook can be a data processing and visualization pipeline

• Are Jupyter notebooks “workflows”?

## Avoiding repetitive code

It all started with a short and simple notebook but how to organize as projects and notebooks grow?

Let’s imagine we wrote this function `fancy_plot` for a hexagonal 2D histogram plot (please try it in your notebook):

```import seaborn as sns

# to get some random numbers
from numpy.random import default_rng

# this one is simple but let us imagine something very lengthy
def fancy_plot(x_values, y_values, color):
"""
Fancy function creating fancy plots.
"""
sns.jointplot(x=x_values, y=y_values, kind="hex", color=color)

rng = default_rng()

x_values = rng.standard_normal(500)
y_values = rng.standard_normal(500)

# call our function
fancy_plot(x_values, y_values, "#4cb391")

other_x_values = rng.standard_normal(500)
other_y_values = rng.standard_normal(500)

# call our function again, this time with other data
fancy_plot(other_x_values, other_y_values, "#fc9272")
```

Now we would like to use this function in 5 other notebooks without duplicating it over all of the notebooks (imagine the function is very lengthy).

It can be useful to create a Python file `myplotfunctions.py` in the same folder as the notebooks (you can change the name) and place this code into `myplotfunctions.py`:

```import seaborn as sns

# this one is simple but let us imagine something very lengthy
def fancy_plot(x_values, y_values, color):
"""
Fancy function creating fancy plots.
"""
sns.jointplot(x=x_values, y=y_values, kind="hex", color=color)
```

Now we can simplify our notebook:

```# to get some random numbers
from numpy.random import default_rng

from myplotfunctions import fancy_plot

rng = default_rng()

x_values = rng.standard_normal(500)
y_values = rng.standard_normal(500)

# call our function
fancy_plot(x_values, y_values, "#4cb391")

other_x_values = rng.standard_normal(500)
other_y_values = rng.standard_normal(500)

# call our function again, this time with other data
fancy_plot(other_x_values, other_y_values, "#fc9272")
```