@@ -122,7 +122,7 @@ If everything is properly configured, then adding LaTeX is trivial
122122
123123``` {code-cell} python3
124124fig, ax = plt.subplots()
125- ax.plot(x, y, 'r-', linewidth=2, label='$y=\sin(x)$', alpha=0.6)
125+ ax.plot(x, y, 'r-', linewidth=2, label=r '$y=\sin(x)$', alpha=0.6)
126126ax.legend(loc='upper center')
127127plt.show()
128128```
@@ -131,7 +131,7 @@ Controlling the ticks, adding titles and so on is also straightforward
131131
132132``` {code-cell} python3
133133fig, ax = plt.subplots()
134- ax.plot(x, y, 'r-', linewidth=2, label='$y=\sin(x)$', alpha=0.6)
134+ ax.plot(x, y, 'r-', linewidth=2, label=r '$y=\sin(x)$', alpha=0.6)
135135ax.legend(loc='upper center')
136136ax.set_yticks([-1, 0, 1])
137137ax.set_title('Test plot')
@@ -163,7 +163,7 @@ x = np.linspace(-4, 4, 150)
163163for i in range(3):
164164 m, s = uniform(-1, 1), uniform(1, 2)
165165 y = norm.pdf(x, loc=m, scale=s)
166- current_label = f '$\mu = {m:.2}$'
166+ current_label = rf '$\mu = {m:.2}$'
167167 ax.plot(x, y, linewidth=2, alpha=0.6, label=current_label)
168168ax.legend()
169169plt.show()
@@ -186,7 +186,7 @@ for i in range(num_rows):
186186 m, s = uniform(-1, 1), uniform(1, 2)
187187 x = norm.rvs(loc=m, scale=s, size=100)
188188 axes[i, j].hist(x, alpha=0.6, bins=20)
189- t = f '$\mu = {m:.2}, \quad \sigma = {s:.2}$'
189+ t = rf '$\mu = {m:.2}, \quad \sigma = {s:.2}$'
190190 axes[i, j].set(title=t, xticks=[-4, 0, 4], yticks=[])
191191plt.show()
192192```
@@ -419,7 +419,7 @@ x = np.linspace(-4, 4, 150)
419419for i in range(3):
420420 m, s = uniform(-1, 1), uniform(1, 2)
421421 y = norm.pdf(x, loc=m, scale=s)
422- current_label = f '$\mu = {m:.2}$'
422+ current_label = rf '$\mu = {m:.2}$'
423423 ax.plot(x, y, linewidth=2, alpha=0.6, label=current_label)
424424ax.legend()
425425plt.show()
@@ -462,8 +462,9 @@ Place all the curves in the same figure.
462462
463463The output should look like this
464464
465- ``` {figure } /_static/lecture_specific/matplotlib/matplotlib_ex1.png
465+ ``` {image } /_static/lecture_specific/matplotlib/matplotlib_ex1.png
466466:scale: 130
467+ :align: center
467468```
468469
469470``` {exercise-end}
0 commit comments