Skip to content

Commit a61d45d

Browse files
committed
tests - add a test for fig-format with matplotlib
1 parent 38693cb commit a61d45d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: Get SVG from matplotlib
3+
format:
4+
html:
5+
fig-format: svg
6+
_quarto:
7+
tests:
8+
html:
9+
ensureHtmlElements:
10+
- ['figure.figure img[src$=".svg"]']
11+
- ['figure.figure img[src$=".png"]']
12+
---
13+
14+
```{python}
15+
import matplotlib.pyplot as plt
16+
import numpy as np
17+
18+
fig, ax = plt.subplots()
19+
20+
x = np.linspace(0, 4 * np.pi, 100)
21+
y1 = np.sin(x)
22+
y2 = np.cos(x)
23+
24+
ax.set_title("Sine and Cosine")
25+
ax.plot(x, y1)
26+
ax.plot(x, y2)
27+
ax.legend(["Sine", "Cosine"])
28+
```

0 commit comments

Comments
 (0)