Skip to content

Commit f51fe5e

Browse files
committed
update registry of plt backend from toml
1 parent 0bef5df commit f51fe5e

File tree

11 files changed

+23
-16
lines changed

11 files changed

+23
-16
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Pygame Matplotlib Backend
22

3-
This is an attempt to create a dedicated backend for matplotlib
4-
in pygame.
3+
Create plots in pygame.
54

6-
The matplotlib ```Figure``` object is replaced by a ```FigureSurface``` object
7-
which inherits from both ```matplotlib.figure.Figure``` and
8-
```pygame.Surface```.
95

106
Note that the library is in an experimental developement stage and not
117
all features of standard matplotlib backends are implement at the moment.
@@ -21,7 +17,7 @@ First you will need to specify that you want to use pygame backend.
2117
```python
2218
# Select pygame backend
2319
import matplotlib
24-
matplotlib.use('module://pygame_matplotlib.backend_pygame')
20+
matplotlib.use('pygame')
2521
```
2622

2723
Then you can use matplotlib as you usually do.
@@ -64,6 +60,14 @@ the game loop.
6460

6561
See examples in test.py or test_show.py
6662

63+
64+
## How it works in the back
65+
66+
The matplotlib ```Figure``` object is replaced by a ```FigureSurface``` object
67+
which inherits from both ```matplotlib.figure.Figure``` and
68+
```pygame.Surface```.
69+
70+
6771
## Current implementation
6872

6973
Support mainly the basic plotting capabilities.

pygame_matplotlib/backend_pygame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
with ::
66
77
import matplotlib
8-
matplotlib.use("'module://pygame_matplotlib.backend_pygame'")
8+
matplotlib.use("pygame")
99
"""
1010
from __future__ import annotations
1111

pygame_matplotlib/gui_window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .backend_pygame import FigureSurface
1010
import matplotlib
1111

12-
matplotlib.use("module://pygame_matplotlib.backend_pygame")
12+
matplotlib.use("pygame")
1313

1414

1515
class UIPlotWindow(pygame_gui.elements.ui_window.UIWindow):

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ keywords = [
2929
"plot",
3030
]
3131

32+
# Self register the backend in matplotlib
33+
[project.entry-points."matplotlib.backend"]
34+
pygame = "pygame_matplotlib.backend_pygame"
3235

3336

3437
[project.urls]

test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pygame
55

66
import matplotlib
7-
matplotlib.use('module://pygame_matplotlib.backend_pygame')
7+
matplotlib.use('pygame')
88

99
import matplotlib.pyplot as plt
1010
import matplotlib.figure as fg

test_blitting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import matplotlib
22
import matplotlib.pyplot as plt
33

4-
matplotlib.use('module://pygame_matplotlib.backend_pygame')
4+
matplotlib.use('pygame')
55
import numpy as np
66

77
x = np.linspace(0, 2 * np.pi, 100)

test_blitting_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import matplotlib.pyplot as plt
22
import numpy as np
33
import matplotlib
4-
matplotlib.use('module://pygame_matplotlib.backend_pygame')
4+
matplotlib.use('pygame')
55

66
class BlitManager:
77
def __init__(self, canvas, animated_artists=()):

test_in_pygame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
import matplotlib
4-
matplotlib.use('module://pygame_matplotlib.backend_pygame')
4+
matplotlib.use('pygame')
55
#matplotlib.use('Qt4Agg')
66

77
import matplotlib.pyplot as plt

test_plt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import matplotlib
77

8-
matplotlib.use("module://pygame_matplotlib.backend_pygame")
8+
matplotlib.use("pygame")
99
# matplotlib.use('Qt4Agg')
1010

1111
import matplotlib.pyplot as plt

test_save.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pygame
55

66
import matplotlib
7-
matplotlib.use('module://pygame_matplotlib.backend_pygame')
7+
matplotlib.use('pygame')
88
#matplotlib.use('Qt4Agg')
99

1010
import matplotlib.pyplot as plt

0 commit comments

Comments
 (0)