Markdown cells are great way to provide documentation to the computations you're presenting.
You can read more about the markdown syntax: https://www.markdownguide.org/basic-syntax/
You can add HTML elements to any Markdown file. For example, next code:
<span style="color:">some styled text</span>
results in: some styled text
Reference: https://ipython.readthedocs.io/en/stable/interactive/magics.html
For instance, with %%HTML
cell magic, you can insert a YouTube video in your notebook as an iframe in separate cell:
%%HTML
<iframe height="280" src="https://www.youtube.com/embed/HW29067qVWk" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Or execute bash commands, with %%bash
magic:
%%bash
printf "The date is: `date` \n\n"
printf "And your fortune is:\n `fortune`"
import numpy as np
import matplotlib.pyplot as plt
X = np.arange(1,10)
Y = X**2
plt.scatter(X, Y)
import seaborn as sns
sns.set()
tips = sns.load_dataset("tips")
sns.relplot(x="total_bill", y="tip", col="time",
hue="sex", style="smoker", size="size",
data=tips);
You can see all keyboard shortcuts by:
On Jupyter Notebook:
Menu -> Help -> Keyboard Shortcuts
On Jupyter Lab:
Menu->Settings->Advanced Settings Editor->Keyboard Shortcuts
But here are some of the most often used:
in both cell modes:
Ctrl + S
- save and checkpointShift + Enter
- run the current cell, select belowin command mode:
Enter
- take you into edit mode
Y
- change the cell type to Code
M
- change the cell type to Markdown
A
- insert cell above
B
- insert cell below
X
- cut selected cells
C
- copy selected cellsV
- paste cells belowShift + V
- paste cells above
D+D
- delete selected cells
Z
- undo cell deletionIn cell edit mode:
Ctrl + Z
- undo
Esc
- take you into command mode
Tab
- code completion or indentShift + Tab
- tooltip and documentationCtrl + ]
- indentCtrl + [
- dedent
Ctrl + A
- select all
Ctrl + Z
- undoOne of the greatest features of Jupyter is that it supports the Command Palette which gives you fast access to all commands by fuzzy search.
Open it in Jupyter Notebook:
CTRL+SHIFT+P
or CTRL+SHIFT+F