2.4.3 Adding Markdown to Notebooks
Markdown helps to add structure to documents and improve readability. As with typical markdown, you can easily specify headings and subheadings, as demonstrated in the following example:
# Heading 1 ## Heading 2 ### Heading 3
This code produces the following:
You can also embolden or italicise your text:
**Here is an example of emboldening** and *italicization*.
Bullet points or numbered lists can also easily be used:
* Here are * some bullet points 1. Here is 2. a list 1. and sublist
Markdown in Jupyter notebooks also allows you to drop in non‐executable code, in cases where code is being used illustratively, rather than being intended for execution. This is done using backticks:
`code = example`
As well as being able to incorporate illustrative code, the markdown also makes it very easy to incorporate mathematical symbols and equations, as it supports LaTeX:
$y = \sum:{i=0}^{10}{x^i}$
2.4.4 A Simple Plotting Example
Plotting in Jupyter notebooks is an easy and powerful way to visualise data and interact with the visualisations. Below we show a simple plotting example:
Note the “%matplotlib inline” line in the above code. This will produce an in‐line plot within the notebook, as follows:
But Jupyter also provides tools for creating interactive plots. This can be achieved by replacing the “%matplotlib inline” instruction to “%matplotlib notebook,” producing a plot as follows:
This interactive plot allows the user to easily pan, zoom, and download the plot.
2.4.5 Summary
In this section, we have seen how Jupyter notebooks can be used to create dynamic documents with embedded code. These notebooks facilitate intuitive knowledge transfer, helping you to convey complex scientific and mathematical concepts with the aid of executable code and interactive visualisations. For more information, and to see further examples of what can be achieved with Jupyter notebooks, please visit the Jupyter website at: jupyter.org
Конец ознакомительного фрагмента.
Текст предоставлен ООО «ЛитРес».
Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.
Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.