Skip to content

Commit f4d4027

Browse files
committed
Add example of plot usage to README
1 parent c1a8dbb commit f4d4027

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ All other circles are waypoints that must be visited on the way down.
3232
## Concept
3333

3434
The idea is for students to use the surface implemented in `soapboxslide` to simulate the dynamics of a particle (or a connected set of particles) sliding down.
35-
In addition to correctly implementing the dynamics, students are instructed to find the physical parameters that allow the point mass(es) to reach the final target as quickly as possible, without missing any of the intermediate waypoints.
35+
In addition to correctly implementing the dynamics, students are instructed to find the physical parameters for which the point mass(es) to reach the final target as quickly as possible, without missing any of the intermediate waypoints.
3636

3737
Two classes of physical models can be considered:
3838

@@ -123,10 +123,31 @@ Note that the above surface plots show dashed circles centered on the waypoints,
123123

124124
The `Slide` class also features two potentially useful methods:
125125

126-
- `Slide.plot` can be used to prepare a drawing of the slide on which one can overlay additional results.
127126
- `Slide.get_hits` can be used to check which waypoints were reached by a given trajectory.
127+
- `Slide.plot` can be used to prepare a drawing of the slide on which one can overlay additional results.
128+
It supports several keyword arguments to customize the surface.
129+
130+
This is a minimal example using the `Slide.plot` method, to which one can easily add more matplotlib code:
131+
132+
```python
133+
import matplotlib.pyplot as plt
134+
135+
from soapboxslide import Slide
136+
137+
# Prepare plot with slide surface
138+
slide = Slide.from_file("boxcar_blitz.toml")
139+
fig, ax = plt.subplots(figsize=(8, 7))
140+
slide.plot(fig, ax)
141+
142+
# Customize plot
143+
ax.set(title="You can put here whatever you want")
144+
ax.plot([5.0, 20.0, 9.0], [36.0, 1.0, 5.0], "g-", lw=4)
145+
146+
# Save
147+
fig.savefig("myplot.jpg")
148+
```
128149

129-
Consult their respective docstrings for more information on how to use these methods.
150+
Consult the docstrings for more information on how to use the `get_hits` and `plot` methods.
130151

131152
## Storing and Sharing Trajectory Data
132153

0 commit comments

Comments
 (0)