Creating a Notebook

You are here:

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

…and more!

Let’s start by creating a simple Notebook:

https://lh3.googleusercontent.com/gy--n4Sw9yv-x0A-V-t0PSWYn_cMpN5Suk5Ss4mUNrGT4QQJvkdkKIWIOfFFSf5OEg6Fd0pdHDdztyK_fAmCA1gECbFuD3cxKcbJUSKSeK7SsAzXce8NohmFuLBClekPuoXQg8Y

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:

https://lh4.googleusercontent.com/RuS70c6eBzs6FK5VEah8mrfqUf4u11pZXfHVbrrq-OOdpBvtkIianO8cusWVtUFupNWYmGxcc40rd3r2ZQ05MY0HHfnIBoWKggurvm6elVA6tYkVWWnNqYXrv0GNQWBJGhMI6Oc

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:

https://lh5.googleusercontent.com/yfsd-tggB1mC7jZLE8_d2xgMhQvwlFdUklC7ClivHGWiQ6JwhhfGuWUAZJu4xVU_qdmJ_V6ADnRcQmj78rriL-OqoxL_1EZwuzn8OPqYBOfgxBbjZFbN5Mhua7LVwFjXxj_j2x0

“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:

https://lh3.googleusercontent.com/Yv6I4HftQu9VKMA-BIEpdM1ljujRN8H9MwsQA4TRBebIfcTRj40PvBnmvjzHmVLy-oa7CzYYcrpi_zNMaiAsk_PjHrqW-AoYIjNvpQeARshC4_QH7OXTjQVId_6ipPpanxdMHM0

Note that since we did not hide the input for section #1, the code is also visible along with the chart.

Previous Running Code and Models Against Datasets
Table of Contents