Skip to content

Peter4137/mplstadium

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Python plotting library to visualize stadium data

Lint and Test

Quick start

Install the package using pip (or pip3).

pip install mplstadium

Plot an outdoor 400m running track, with the origin at the centre of the track:

from mplstadium.utils import OutdoorAthleticsTrack2D
from matplotlib import pyplot as plt

track = OutdoorAthleticsTrack2D()
fig, ax = track.draw()
ax.set_aspect("equal")
plt.show()

Plot an Olympic Velodrome in 3D and a trajectory on the surface:

from mplstadium.utils import OlympicVelodrome3D
import numpy as np
from matplotlib import pyplot as plt

track = OlympicVelodrome3D()
fig, ax = track.draw()

s = np.linspace(0, 250, 250)
d = 4 + 4 * np.sin(s / 10)

track.trajectory(s, d, c="r")

ax.set_aspect("equal")
ax.axis("off")
plt.show()

Define a custom Stadium geometry and plot scatter points over it:

from mplstadium import Stadium3D
import numpy as np
from matplotlib import pyplot as plt

stadium_length = 20 + 2 * np.pi * 10

track = Stadium3D(
    length=stadium_length,
    radius=10,
    width=20,
    straight_banking=30,
    curve_banking=30,
    lane_widths=[20],
    surface_color="black",
    infield_color="green",
)
fig, ax = track.draw()

s = np.random.uniform(0, stadium_length, 200)
d = np.random.uniform(0, 20, 200)

track.scatter(s, d, c="r", alpha=1)

ax.set_aspect("equal")
ax.axis("off")
plt.show()

Development

To run the test suite:

poetry run pytest --mpl

To regenerate the baseline images for the plot tests:

poetry run pytest --mpl-generate-path=baseline

License

MIT

About

A Python plotting library for visualising stadium data

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages