Skip to content

Commit f0c8530

Browse files
Add legend to sine wave example
1 parent c9d7147 commit f0c8530

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

docs/environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
dependencies:
55
- matplotlib
6-
- pip >=21.3.1
6+
- pip >= 21.3.1
77
- pip:
88
- furo >= 2023.8.17
99
- sphinx >= 7.2.2

examples/sine_waves.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@
2424
plot.left_axis.set_ylabel(r"$\sin(\omega t)$", color="b")
2525
plot.left_axis.tick_params(axis="y", labelcolor="b")
2626

27-
plot.add_right("3cos", "g-")
28-
plot.right_axis.set_ylabel(r"$3 \cos(\omega t)$", color="g")
27+
plot.add_right("3 cos", "g-")
28+
plot.add_right("1.5 cos", "g:")
29+
plot.right_axis.set_ylabel(r"Cosines", color="g")
2930
plot.right_axis.tick_params(axis="y", labelcolor="g")
31+
32+
plot.legend()
3033
plot.redraw()
3134

3235
for i in range(500):
3336
t = i * TIMESTEP
3437
plot.send("sin", math.sin(OMEGA * t))
35-
plot.send("3cos", 3 * math.cos(OMEGA * t))
38+
plot.send("3 cos", 3 * math.cos(OMEGA * t))
39+
plot.send("1.5 cos", 1.5 * math.cos(OMEGA * t))
3640
plot.update()

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies = [
3131
]
3232

3333
[project.urls]
34+
Homepage = "https://github.com/stephane-caron/matplotlive"
3435
Source = "https://github.com/stephane-caron/matplotlive"
3536
Tracker = "https://github.com/stephane-caron/matplotlive/issues"
3637
Changelog = "https://github.com/stephane-caron/matplotlive/blob/main/CHANGELOG.md"

0 commit comments

Comments
 (0)