Markdown in a Jupyter notebook file

Markdown in a Jupyter notebook file#

\(\text{Task 3.1:}\)

Run the cell below to create an image which is stored in a subdirectory auxiliary files. Then, show the figure in the next markdown cell.

import numpy as np
import matplotlib.pyplot as plt
import os

# Create the _figure directory if it doesn't exist
os.makedirs('auxiliary_files', exist_ok=True)

x = np.linspace(0, 2 * np.pi, 100)
y = np.sin(x)

# Create a simple plot
plt.figure(figsize=(8, 6))
plt.plot(x, y, 'b-', linewidth=2, label='sin(x)')
plt.xlabel('x')
plt.ylabel('sin(x)')
plt.title('Simple Sine Wave')
plt.grid(True, alpha=0.3)
plt.legend()
plt.savefig('auxiliary_files/sine_wave.svg', bbox_inches='tight')
plt.close()

print("Figure saved to auxiliary_files/sine_wave.svg")
Figure saved to auxiliary_files/sine_wave.svg

\(\text{Solution 3.1:}\)

The required markdown syntax is: ![](./auxiliary_files/sine_wave.svg)

By Tom van Woudenberg, Delft University of Technology. CC BY 4.0, more info on the Credits page of Workbook.