Skip to main content

A python plotting library for visualisation of stadium data

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mplstadium-0.2.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

mplstadium-0.2.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file mplstadium-0.2.0.tar.gz.

File metadata

  • Download URL: mplstadium-0.2.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.15 Linux/6.8.0-1014-azure

File hashes

Hashes for mplstadium-0.2.0.tar.gz
Algorithm Hash digest
SHA256 661027a88c6e130a00ea878b99e726255f5c31fdacb5f94470c8d33379105945
MD5 7fa7a87dc513ebaf3cce7e360521de53
BLAKE2b-256 2001cfc9c87bda3648d960cb4f8439dc92c2d3416bd93ab8524f6510cc24c920

See more details on using hashes here.

File details

Details for the file mplstadium-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mplstadium-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.15 Linux/6.8.0-1014-azure

File hashes

Hashes for mplstadium-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 968833a7790892057f6fad852a236b73f810456b7658e64f34f5b36edd386ba2
MD5 6c02c669b6d4860d2808a62d39e86a21
BLAKE2b-256 68231ba79715338240390243c343f0401125f3b8cf2d2123ae38d40f673492f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page