diff --git a/src/sk8plotlib/maps/sinepark.py b/src/sk8plotlib/maps/sinepark.py index 8531440..c05e73b 100644 --- a/src/sk8plotlib/maps/sinepark.py +++ b/src/sk8plotlib/maps/sinepark.py @@ -3,16 +3,39 @@ from matplotlib import pyplot as plt from matplotlib.figure import Figure -def sinepark() -> Figure: - """Simple example map. Full o' sines.""" +def sinepark( + x_ramps=9, + y_ramps=9, + ramp_width=4 * np.pi, + ramp_height=10.0, + x_spacing=2.5, + y_spacing=5.0, + ramp_resolution=50, +) -> Figure: + """Simple example map. Full of trigonometric ramps.""" + fig, ax = plt.subplots(figsize=(8, 4), dpi=300) + rng = np.random.default_rng(seed=43) - x = np.linspace(-np.pi, 50 * np.pi, num=1000) - y = np.cos(x) - x * 0.2 * np.cos(x) - 0.5*x + ax.plot([-1, 1], [0, 0]) - x = x * 2 - 1 - y = y - 2 - y = y * 3 + width = x_ramps * ramp_width + (x_ramps - 1) * x_spacing + height = y_ramps * ramp_height + (y_ramps - 1) * y_spacing + + functions = [np.sin, np.sin, np.sinh, np.cosh, np.tanh] + + for y_start in np.linspace(-y_spacing, -height - y_spacing, num=y_ramps): + for x_start in np.linspace(-width/2, width/2, num=x_ramps): + x = np.linspace(x_start, x_start + ramp_width, num=ramp_resolution) + x += rng.uniform(x_spacing * -0.5, x_spacing * 0.5) + + x_function = np.linspace(-np.pi, np.pi, num=ramp_resolution) * rng.choice( + [-1, 1] + ) + rng.uniform(-np.pi / 2, np.pi / 2) + function = functions[rng.integers(0, high=len(functions))] + y = function(x_function) * rng.choice([-1, 1]) + rng.uniform(-1, 1) * x_function + y -= y.min() + y = (y / y.max()) * ramp_height * rng.uniform(0.2, 1.0) + y += y_start - ramp_height + ax.plot(x, y, color=plt.get_cmap("viridis")(rng.uniform()), lw=2.0) - fig, ax = plt.subplots(figsize=(8, 4), dpi=300) - ax.plot(x, y) return fig