Creating a Notebook
Creating a Notebook is very similar to creating code. Similarly to the MiPasa Code page/section (on the top/main menu) we have a Notebooks section. You can visit it either by clicking on the Notebooks from the top menu, or by going directly to the Notebooks section by visiting this URL: https://app.mipasa.org/notebooks
There are numerous presentation advantages for Notebooks compared to Code, even though writing simple scripts is a lot easier. For example, in a Notebook you can:
- Use markdown to provide headings, explanation sections, and separation between charts;
- Use Pandas to display data tables;
- Use Plotly to display interactive, live charts
Let’s start by creating a simple Notebook:
Note how we created one default line of code for you, but this code was not executed yet, so there is no output.
Click Run to execute the notebook and fill in all outputs:
You can configure the individual cells of the Notebook by clicking on the settings icon next to any cell.This will bring up a panel that allows you to pick the type of the cell, move it up or down, or hide inputs or outputs (this will be applied in the View, or presentation mode — i.e. when the users view your notebook).
Let’s add a new Markdown cell:
“Hide input” in the settings means that the markdown input will not be visible in the published article: more on this later, in the “Sharing your Code or Notebook” chapter.
Adding an Interactive Chart to a Notebook
In this tutorial, we will simply use the official example from Plotly’s documentation.
Add this code to the Python section of your Notebook, and run:
import plotly.express as px df = px.data.iris() fig = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width', color='species') fig.show()
Now, if you switch to the View mode, you should be able to see a 3-D interactive chart, like this:
Note that since we did not hide the input for section #1, the code is also visible along with the chart.