mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-13 13:02:56 +00:00
Better tests directory structure (#2231)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
# type: ignore
|
||||
# Matplotlib: Create a simple plot example.
|
||||
# Refs: https://matplotlib.org/stable/gallery/lines_bars_and_markers/simple_plot.html
|
||||
|
||||
# Optional test with [Matplotlib Jupyter Integration](https://github.com/matplotlib/ipympl)
|
||||
# %matplotlib widget
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
# Data for plotting
|
||||
t = np.arange(0.0, 2.0, 0.01)
|
||||
s = 1 + np.sin(2 * np.pi * t)
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
ax.plot(t, s)
|
||||
|
||||
ax.set(
|
||||
xlabel="time (s)",
|
||||
ylabel="voltage (mV)",
|
||||
title="About as simple as it gets, folks",
|
||||
)
|
||||
ax.grid()
|
||||
|
||||
# Note that the test can be run headless by checking if an image is produced
|
||||
file_path = "/tmp/test.png"
|
||||
fig.savefig(file_path)
|
||||
print(f"File {file_path} saved")
|
@@ -0,0 +1,25 @@
|
||||
# Matplotlib: Test tex fonts
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
matplotlib.rcParams["pgf.texsystem"] = "pdflatex"
|
||||
matplotlib.rcParams.update(
|
||||
{
|
||||
"font.family": "serif",
|
||||
"font.size": 18,
|
||||
"axes.labelsize": 20,
|
||||
"axes.titlesize": 24,
|
||||
"figure.titlesize": 28,
|
||||
}
|
||||
)
|
||||
matplotlib.rcParams["text.usetex"] = True
|
||||
|
||||
fig, ax = plt.subplots(1, 1)
|
||||
x = [1, 2]
|
||||
y = [1, 2]
|
||||
ax.plot(x, y, label="a label")
|
||||
ax.legend(fontsize=15)
|
||||
|
||||
file_path = "/tmp/test_fonts.png"
|
||||
fig.savefig(file_path)
|
||||
print(f"File {file_path} saved")
|
Reference in New Issue
Block a user