Pygame Matplotlib Backend
Create plots in pygame.
Note that the library is in an experimental developement stage and not all features of standard matplotlib backends are implement at the moment.
Installation
pip install pygame-matplotlib
Usage
First you will need to specify that you want to use pygame backend.
# Select pygame backend
import matplotlib
matplotlib.use('pygame')
Then you can use matplotlib as you usually do.
# Standard matplotlib syntax
import matplotlib.pyplot as plt
fig, ax = plt.subplots() # Create a figure containing a single axes.
ax.plot([1, 2, 3, 4], [1, 4, 2, 3]) # Plot some data on the axes.
plt.show()
Or you can include the plot in your game using the fact that a Figure is
also a pygame.Surface with this backend.
import pygame
import pygame.display
fig, axes = plt.subplots(1, 1,)
axes.plot([1,2], [1,2], color='green', label='test')
fig.canvas.draw()
screen = pygame.display.set_mode((800, 600))
# Use the fig as a pygame.Surface
screen.blit(fig, (100, 100))
show = True
while show:
for event in pygame.event.get():
if event.type == pygame.QUIT:
# Stop showing when quit
show = False
pygame.display.update()
Note that if you want to update the plot during the game, you might
need to call fig.canvas.draw() and screen.blit(fig) during
the game loop.
See examples in test.py or test_show.py
How it works in the back
The matplotlib Figure object is replaced by a FigureSurface object
which inherits from both matplotlib.figure.Figure and
pygame.Surface.
Current implementation
Support mainly the basic plotting capabilities.
Metadata
Release files for pygame-matplotlib 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pygame_matplotlib-0.5.tar.gz | 118.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pygame_matplotlib-0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 129.2 kB
Release files / pygame_matplotlib-0.5.tar.gz
| Download URL | pygame_matplotlib-0.5.tar.gz |
|---|---|
| Size | 118.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98d78e05dc1c8e508f3e9c37665aaf94856dd0cad4610fb69575cd53ee2b3292
|
|
BLAKE2b-256 checksum How to use checksums |
465cfc7aaf8ea6683318427b9854f151d794168f1cef860c382d4ef8c9e39b00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Release files / pygame_matplotlib-0.5-py3-none-any.whl
| Download URL | pygame_matplotlib-0.5-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e04ab3950e8ecd3b43aa6c1ac9a56a9c6a573d5dfcf226ab03622497763e76c
|
|
BLAKE2b-256 checksum How to use checksums |
d7608d4608440ec841247a9612d94d24052fe5189c865580fd35ea53060c0424
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Security for pygame-matplotlib 0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.