maxplotlibx 0.1.7__tar.gz → 0.1.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {maxplotlibx-0.1.7/src/maxplotlibx.egg-info → maxplotlibx-0.1.9}/PKG-INFO +55 -27
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/README.md +53 -25
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/pyproject.toml +2 -2
- maxplotlibx-0.1.9/src/maxplotlib/backends/plotext/figure.py +147 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/canvas/canvas.py +805 -22
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/subfigure/line_plot.py +1052 -83
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/tests/test_canvas.py +370 -11
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/tests/test_plot.py +4 -4
- maxplotlibx-0.1.9/src/maxplotlib/tests/test_plotext.py +289 -0
- maxplotlibx-0.1.9/src/maxplotlib/tests/test_plotly_backend.py +684 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9/src/maxplotlibx.egg-info}/PKG-INFO +55 -27
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlibx.egg-info/requires.txt +1 -1
- maxplotlibx-0.1.7/src/maxplotlib/backends/plotext/figure.py +0 -51
- maxplotlibx-0.1.7/src/maxplotlib/tests/test_plotext.py +0 -135
- maxplotlibx-0.1.7/src/maxplotlib/tests/test_plotly_backend.py +0 -338
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/LICENSE +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/setup.cfg +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/__init__.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/backends/matplotlib/utils.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/backends/plotext/__init__.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/backends/plotly/__init__.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/backends/plotly/utils.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/canvas/__init__.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/colors/__init__.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/colors/colors.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/linestyle/__init__.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/linestyle/linestyle.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/objects/__init__.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/objects/node.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/objects/path.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/subfigure/__init__.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/subfigure/subfigure.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/tests/test_flame_chart.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/tests/test_gantt_chart.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/tests/test_imports.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/tests/test_styles_and_colors.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/utils/__init__.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlib/utils/options.py +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlibx.egg-info/SOURCES.txt +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlibx.egg-info/dependency_links.txt +0 -0
- {maxplotlibx-0.1.7 → maxplotlibx-0.1.9}/src/maxplotlibx.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: maxplotlibx
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.9
|
|
4
4
|
Summary: A reproducible plotting module with various backends and export options.
|
|
5
5
|
Author: Max
|
|
6
6
|
Project-URL: Source, https://github.com/max-models/maxplotlib
|
|
@@ -12,7 +12,7 @@ License-File: LICENSE
|
|
|
12
12
|
Requires-Dist: matplotlib
|
|
13
13
|
Requires-Dist: pint
|
|
14
14
|
Requires-Dist: plotly
|
|
15
|
-
Requires-Dist: plotext
|
|
15
|
+
Requires-Dist: plotext<7,>=6.0
|
|
16
16
|
Requires-Dist: tikzfigure[vis]>=0.3.0
|
|
17
17
|
Provides-Extra: test
|
|
18
18
|
Requires-Dist: pytest; extra == "test"
|
|
@@ -82,6 +82,33 @@ canvas.show()
|
|
|
82
82
|
|
|
83
83
|

|
|
84
84
|
|
|
85
|
+
Use `canvas.plot(x, y)` to add data directly to a canvas. When you want
|
|
86
|
+
to explicitly render an already-built canvas, use `canvas.render(...)`.
|
|
87
|
+
The older `canvas.plot(backend=...)` spelling is still supported for
|
|
88
|
+
compatibility, but emits a `FutureWarning`.
|
|
89
|
+
|
|
90
|
+
Add several lines at once with shared styling:
|
|
91
|
+
|
|
92
|
+
``` python
|
|
93
|
+
canvas.plot_many(
|
|
94
|
+
[(x, np.sin(x)), (x, np.cos(x))],
|
|
95
|
+
labels=["sin(x)", "cos(x)"],
|
|
96
|
+
linewidth=2,
|
|
97
|
+
)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Common figure and axis settings can be grouped with `configure()`:
|
|
101
|
+
|
|
102
|
+
``` python
|
|
103
|
+
canvas.configure(
|
|
104
|
+
title="Trigonometry",
|
|
105
|
+
xlabel="Angle",
|
|
106
|
+
ylabel="Value",
|
|
107
|
+
grid=True,
|
|
108
|
+
facecolor="whitesmoke",
|
|
109
|
+
)
|
|
110
|
+
```
|
|
111
|
+
|
|
85
112
|
For Matplotlib-specific customization, pass method calls declaratively.
|
|
86
113
|
Figure methods run once and axes methods run for every subplot,
|
|
87
114
|
providing access to any Matplotlib API without requiring a maxplotlib
|
|
@@ -186,37 +213,38 @@ parts of a mixed canvas, explicitly opt into skipping unsupported
|
|
|
186
213
|
primitives:
|
|
187
214
|
|
|
188
215
|
``` python
|
|
189
|
-
plotly_canvas.
|
|
216
|
+
plotly_canvas.render(backend="plotly", allow_unsupported=True)
|
|
190
217
|
```
|
|
191
218
|
|
|
192
219
|
Render the same line graph directly in the terminal with the `plotext`
|
|
193
220
|
backend:
|
|
194
221
|
|
|
195
222
|
``` python
|
|
196
|
-
terminal_fig = canvas.
|
|
223
|
+
terminal_fig = canvas.render(backend="plotext")
|
|
197
224
|
print(terminal_fig.build(keep_colors=False))
|
|
198
225
|
```
|
|
199
226
|
|
|
227
|
+
Trigonometry
|
|
200
228
|
Runtime
|
|
201
|
-
|
|
202
|
-
1.00
|
|
203
|
-
│
|
|
204
|
-
│
|
|
205
|
-
0.67
|
|
206
|
-
│
|
|
207
|
-
0.33
|
|
208
|
-
│
|
|
209
|
-
│▗▞▘
|
|
210
|
-
0.00
|
|
211
|
-
|
|
212
|
-
│
|
|
213
|
-
-0.33
|
|
214
|
-
│
|
|
215
|
-
-0.67
|
|
216
|
-
│
|
|
217
|
-
│
|
|
218
|
-
-1.00
|
|
219
|
-
|
|
229
|
+
┌┬─────────────────┬─────────────────┬─────────────────┬─────────────────┬┐
|
|
230
|
+
1.00┼ ▞▞ sin(x) ──▗▄▞▀▀▀▀▀▙▄▖────────────┼─────────────────┼─────────────▄▄▀▀▀┤
|
|
231
|
+
│ ▞▞ cos(x) ▄▀▘ │ ▝▀▄ │ │ ▄▞▀ ││
|
|
232
|
+
││ ▜▄▘ │ ▀▄ │ │ ▄▛ ││
|
|
233
|
+
0.67┼┼──────▟▀─▀▄──────┼─────────▀▄──────┼─────────────────┼──────▄▀─────────┼┤
|
|
234
|
+
││ ▄▛ ▝▚▖ │ ▚▖ │ │ ▗▞▘ ││
|
|
235
|
+
0.33┼┼──▗▞────────▀▖───┼────────────▝▄───┼─────────────────┼───▗▀────────────┼┤
|
|
236
|
+
││ ▄▀ ▝▚ │ ▚▖ │ │ ▞▘ ││
|
|
237
|
+
│▗▞▘ ▀▖│ ▀▄│ │▗▀ ││
|
|
238
|
+
0.00┼▞────────────────▝▙────────────────▝▚▖────────────────▟▘────────────────▄┤
|
|
239
|
+
││ │▜▖ │▀▄ ▗▛│ ▗▞▘│
|
|
240
|
+
││ │ ▝▙ │ ▝▚ ▟▘ │ ▄▀ ││
|
|
241
|
+
-0.33┼┼─────────────────┼───▚▖────────────┼───▀▖───────▗▞───┼─────────────▞▘──┼┤
|
|
242
|
+
││ │ ▝▄▖ │ ▝▚ ▗▄▘ │ ▟▀ ││
|
|
243
|
+
-0.67┼┼─────────────────┼──────▀▖─────────┼──────▀▄─▗▀──────┼─────────▄▛──────┼┤
|
|
244
|
+
││ │ ▝▜▄ │ ▄▛▘ │ ▗▞▘ ││
|
|
245
|
+
││ │ ▀▄▖ │ ▗▄▀ ▀▄▖ │ ▗▄▀▘ ││
|
|
246
|
+
-1.00┼┼─────────────────┼────────────▝▀▚▄▄▄▄▄▞▀▘───────▝▀▜▄▄▄▄▄▞▀▘────────────┼┤
|
|
247
|
+
└┼─────────────────┼─────────────────┼─────────────────┼─────────────────┼┘
|
|
220
248
|
0.0 1.6 3.1 4.7 6.3
|
|
221
249
|
Duration Time
|
|
222
250
|
|
|
@@ -226,7 +254,7 @@ Or plot with the TikZ backend:
|
|
|
226
254
|
canvas.show(backend="tikzfigure")
|
|
227
255
|
```
|
|
228
256
|
|
|
229
|
-

|
|
230
258
|
|
|
231
259
|
### Horizontal Subplots with TikZ Backend
|
|
232
260
|
|
|
@@ -307,7 +335,7 @@ canvas.show(backend="plotext")
|
|
|
307
335
|
1.0 1.8 3.2 5.6 10.0
|
|
308
336
|
y x
|
|
309
337
|
|
|
310
|
-
<maxplotlib.backends.plotext.figure.PlotextFigure at
|
|
338
|
+
<maxplotlib.backends.plotext.figure.PlotextFigure at 0x1102a0690>
|
|
311
339
|
|
|
312
340
|
### Layers
|
|
313
341
|
|
|
@@ -343,7 +371,7 @@ Show layer 0 only, then layers 0 and 1, then everything:
|
|
|
343
371
|
canvas.show(layers=[0])
|
|
344
372
|
```
|
|
345
373
|
|
|
346
|
-

|
|
347
375
|
|
|
348
376
|
(<Figure size 590.551x324.803 with 1 Axes>,
|
|
349
377
|
array([[<Axes: xlabel='x'>]], dtype=object))
|
|
@@ -354,7 +382,7 @@ Show all layers:
|
|
|
354
382
|
canvas.show()
|
|
355
383
|
```
|
|
356
384
|
|
|
357
|
-

|
|
358
386
|
|
|
359
387
|
(<Figure size 590.551x324.803 with 1 Axes>,
|
|
360
388
|
array([[<Axes: xlabel='x'>]], dtype=object))
|
|
@@ -45,6 +45,33 @@ canvas.show()
|
|
|
45
45
|
|
|
46
46
|

|
|
47
47
|
|
|
48
|
+
Use `canvas.plot(x, y)` to add data directly to a canvas. When you want
|
|
49
|
+
to explicitly render an already-built canvas, use `canvas.render(...)`.
|
|
50
|
+
The older `canvas.plot(backend=...)` spelling is still supported for
|
|
51
|
+
compatibility, but emits a `FutureWarning`.
|
|
52
|
+
|
|
53
|
+
Add several lines at once with shared styling:
|
|
54
|
+
|
|
55
|
+
``` python
|
|
56
|
+
canvas.plot_many(
|
|
57
|
+
[(x, np.sin(x)), (x, np.cos(x))],
|
|
58
|
+
labels=["sin(x)", "cos(x)"],
|
|
59
|
+
linewidth=2,
|
|
60
|
+
)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Common figure and axis settings can be grouped with `configure()`:
|
|
64
|
+
|
|
65
|
+
``` python
|
|
66
|
+
canvas.configure(
|
|
67
|
+
title="Trigonometry",
|
|
68
|
+
xlabel="Angle",
|
|
69
|
+
ylabel="Value",
|
|
70
|
+
grid=True,
|
|
71
|
+
facecolor="whitesmoke",
|
|
72
|
+
)
|
|
73
|
+
```
|
|
74
|
+
|
|
48
75
|
For Matplotlib-specific customization, pass method calls declaratively.
|
|
49
76
|
Figure methods run once and axes methods run for every subplot,
|
|
50
77
|
providing access to any Matplotlib API without requiring a maxplotlib
|
|
@@ -149,37 +176,38 @@ parts of a mixed canvas, explicitly opt into skipping unsupported
|
|
|
149
176
|
primitives:
|
|
150
177
|
|
|
151
178
|
``` python
|
|
152
|
-
plotly_canvas.
|
|
179
|
+
plotly_canvas.render(backend="plotly", allow_unsupported=True)
|
|
153
180
|
```
|
|
154
181
|
|
|
155
182
|
Render the same line graph directly in the terminal with the `plotext`
|
|
156
183
|
backend:
|
|
157
184
|
|
|
158
185
|
``` python
|
|
159
|
-
terminal_fig = canvas.
|
|
186
|
+
terminal_fig = canvas.render(backend="plotext")
|
|
160
187
|
print(terminal_fig.build(keep_colors=False))
|
|
161
188
|
```
|
|
162
189
|
|
|
190
|
+
Trigonometry
|
|
163
191
|
Runtime
|
|
164
|
-
|
|
165
|
-
1.00
|
|
166
|
-
│
|
|
167
|
-
│
|
|
168
|
-
0.67
|
|
169
|
-
│
|
|
170
|
-
0.33
|
|
171
|
-
│
|
|
172
|
-
│▗▞▘
|
|
173
|
-
0.00
|
|
174
|
-
|
|
175
|
-
│
|
|
176
|
-
-0.33
|
|
177
|
-
│
|
|
178
|
-
-0.67
|
|
179
|
-
│
|
|
180
|
-
│
|
|
181
|
-
-1.00
|
|
182
|
-
|
|
192
|
+
┌┬─────────────────┬─────────────────┬─────────────────┬─────────────────┬┐
|
|
193
|
+
1.00┼ ▞▞ sin(x) ──▗▄▞▀▀▀▀▀▙▄▖────────────┼─────────────────┼─────────────▄▄▀▀▀┤
|
|
194
|
+
│ ▞▞ cos(x) ▄▀▘ │ ▝▀▄ │ │ ▄▞▀ ││
|
|
195
|
+
││ ▜▄▘ │ ▀▄ │ │ ▄▛ ││
|
|
196
|
+
0.67┼┼──────▟▀─▀▄──────┼─────────▀▄──────┼─────────────────┼──────▄▀─────────┼┤
|
|
197
|
+
││ ▄▛ ▝▚▖ │ ▚▖ │ │ ▗▞▘ ││
|
|
198
|
+
0.33┼┼──▗▞────────▀▖───┼────────────▝▄───┼─────────────────┼───▗▀────────────┼┤
|
|
199
|
+
││ ▄▀ ▝▚ │ ▚▖ │ │ ▞▘ ││
|
|
200
|
+
│▗▞▘ ▀▖│ ▀▄│ │▗▀ ││
|
|
201
|
+
0.00┼▞────────────────▝▙────────────────▝▚▖────────────────▟▘────────────────▄┤
|
|
202
|
+
││ │▜▖ │▀▄ ▗▛│ ▗▞▘│
|
|
203
|
+
││ │ ▝▙ │ ▝▚ ▟▘ │ ▄▀ ││
|
|
204
|
+
-0.33┼┼─────────────────┼───▚▖────────────┼───▀▖───────▗▞───┼─────────────▞▘──┼┤
|
|
205
|
+
││ │ ▝▄▖ │ ▝▚ ▗▄▘ │ ▟▀ ││
|
|
206
|
+
-0.67┼┼─────────────────┼──────▀▖─────────┼──────▀▄─▗▀──────┼─────────▄▛──────┼┤
|
|
207
|
+
││ │ ▝▜▄ │ ▄▛▘ │ ▗▞▘ ││
|
|
208
|
+
││ │ ▀▄▖ │ ▗▄▀ ▀▄▖ │ ▗▄▀▘ ││
|
|
209
|
+
-1.00┼┼─────────────────┼────────────▝▀▚▄▄▄▄▄▞▀▘───────▝▀▜▄▄▄▄▄▞▀▘────────────┼┤
|
|
210
|
+
└┼─────────────────┼─────────────────┼─────────────────┼─────────────────┼┘
|
|
183
211
|
0.0 1.6 3.1 4.7 6.3
|
|
184
212
|
Duration Time
|
|
185
213
|
|
|
@@ -189,7 +217,7 @@ Or plot with the TikZ backend:
|
|
|
189
217
|
canvas.show(backend="tikzfigure")
|
|
190
218
|
```
|
|
191
219
|
|
|
192
|
-

|
|
193
221
|
|
|
194
222
|
### Horizontal Subplots with TikZ Backend
|
|
195
223
|
|
|
@@ -270,7 +298,7 @@ canvas.show(backend="plotext")
|
|
|
270
298
|
1.0 1.8 3.2 5.6 10.0
|
|
271
299
|
y x
|
|
272
300
|
|
|
273
|
-
<maxplotlib.backends.plotext.figure.PlotextFigure at
|
|
301
|
+
<maxplotlib.backends.plotext.figure.PlotextFigure at 0x1102a0690>
|
|
274
302
|
|
|
275
303
|
### Layers
|
|
276
304
|
|
|
@@ -306,7 +334,7 @@ Show layer 0 only, then layers 0 and 1, then everything:
|
|
|
306
334
|
canvas.show(layers=[0])
|
|
307
335
|
```
|
|
308
336
|
|
|
309
|
-

|
|
310
338
|
|
|
311
339
|
(<Figure size 590.551x324.803 with 1 Axes>,
|
|
312
340
|
array([[<Axes: xlabel='x'>]], dtype=object))
|
|
@@ -317,7 +345,7 @@ Show all layers:
|
|
|
317
345
|
canvas.show()
|
|
318
346
|
```
|
|
319
347
|
|
|
320
|
-

|
|
321
349
|
|
|
322
350
|
(<Figure size 590.551x324.803 with 1 Axes>,
|
|
323
351
|
array([[<Axes: xlabel='x'>]], dtype=object))
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "maxplotlibx"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.9"
|
|
8
8
|
description = "A reproducible plotting module with various backends and export options."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -18,7 +18,7 @@ dependencies = [
|
|
|
18
18
|
"matplotlib",
|
|
19
19
|
"pint",
|
|
20
20
|
"plotly",
|
|
21
|
-
"plotext",
|
|
21
|
+
"plotext >= 6.0, < 7",
|
|
22
22
|
"tikzfigure[vis]>=0.3.0",
|
|
23
23
|
]
|
|
24
24
|
[project.optional-dependencies]
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from plotext import figure as _plotext_figure
|
|
8
|
+
|
|
9
|
+
_ANSI_ESCAPE_RE = re.compile(r"\x1B\[[0-?]*[ -/]*[@-~]")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def strip_ansi(text: str) -> str:
|
|
13
|
+
return _ANSI_ESCAPE_RE.sub("", text)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class _Plotext6Axes:
|
|
17
|
+
"""Small compatibility surface for maxplotlib's plotext renderer."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, figure):
|
|
20
|
+
self._figure = figure
|
|
21
|
+
|
|
22
|
+
def _draw(self, signal, label=None):
|
|
23
|
+
if label is not None:
|
|
24
|
+
signal.label(label)
|
|
25
|
+
self._figure.draw(signal)
|
|
26
|
+
|
|
27
|
+
def plot(self, x, y, **kwargs):
|
|
28
|
+
signal = self._figure.signal(x, y, marker=kwargs.get("marker"))
|
|
29
|
+
self._draw(signal, kwargs.get("label"))
|
|
30
|
+
|
|
31
|
+
scatter = plot
|
|
32
|
+
|
|
33
|
+
def bar(self, *args, **kwargs):
|
|
34
|
+
label = kwargs.pop("label", None)
|
|
35
|
+
kwargs.pop("color", None)
|
|
36
|
+
kwargs.pop("fill", None)
|
|
37
|
+
signal = self._figure.bar(*args, **kwargs)
|
|
38
|
+
self._draw(signal, label)
|
|
39
|
+
|
|
40
|
+
def error(self, x, y, *, xerr=None, yerr=None, color=None, label=None):
|
|
41
|
+
signal = self._figure.error(x, y, yerr, xerr, pixel=color)
|
|
42
|
+
self._draw(signal, label)
|
|
43
|
+
|
|
44
|
+
def matrix_plot(self, data, **kwargs):
|
|
45
|
+
signal = self._figure.heatmap(data, symbol=kwargs.get("marker"))
|
|
46
|
+
self._draw(signal)
|
|
47
|
+
|
|
48
|
+
def text(self, label, x, y, **kwargs):
|
|
49
|
+
# Plotext 6 keeps text colour in its marker object; the renderer only
|
|
50
|
+
# needs the portable text/alignment arguments here.
|
|
51
|
+
kwargs.pop("color", None)
|
|
52
|
+
signal = self._figure.text(x, y, label, **kwargs)
|
|
53
|
+
self._figure.draw(signal)
|
|
54
|
+
|
|
55
|
+
def title(self, label):
|
|
56
|
+
self._figure.title(label)
|
|
57
|
+
|
|
58
|
+
def xlabel(self, label):
|
|
59
|
+
self._figure.label(label, axis=0)
|
|
60
|
+
|
|
61
|
+
def ylabel(self, label):
|
|
62
|
+
self._figure.label(label, axis=1)
|
|
63
|
+
|
|
64
|
+
def grid(self, active=True, *_args):
|
|
65
|
+
self._figure.ruler("x").grid(active)
|
|
66
|
+
self._figure.ruler("y").grid(active)
|
|
67
|
+
|
|
68
|
+
def xlim(self, lower=None, upper=None):
|
|
69
|
+
self._figure.ruler("x").lim(lower, upper)
|
|
70
|
+
|
|
71
|
+
def ylim(self, lower=None, upper=None):
|
|
72
|
+
self._figure.ruler("y").lim(lower, upper)
|
|
73
|
+
|
|
74
|
+
def xscale(self, scale):
|
|
75
|
+
self._figure.ruler("x").scale(scale)
|
|
76
|
+
|
|
77
|
+
def yscale(self, scale):
|
|
78
|
+
self._figure.ruler("y").scale(scale)
|
|
79
|
+
|
|
80
|
+
def xticks(self, positions=None, labels=None):
|
|
81
|
+
self._figure.ruler("x").ticks(positions, labels)
|
|
82
|
+
|
|
83
|
+
def yticks(self, positions=None, labels=None):
|
|
84
|
+
self._figure.ruler("y").ticks(positions, labels)
|
|
85
|
+
|
|
86
|
+
def plotsize(self, width=None, height=None):
|
|
87
|
+
self._figure.plot_size(width, height)
|
|
88
|
+
|
|
89
|
+
def horizontal_line(self, position, **kwargs):
|
|
90
|
+
kwargs.pop("color", None)
|
|
91
|
+
self._figure.line(position, orientation=0, **kwargs)
|
|
92
|
+
|
|
93
|
+
def vertical_line(self, position, **kwargs):
|
|
94
|
+
kwargs.pop("color", None)
|
|
95
|
+
self._figure.line(position, orientation=1, **kwargs)
|
|
96
|
+
|
|
97
|
+
def subplots(self, rows=None, cols=None):
|
|
98
|
+
self._figure.subplots(rows, cols)
|
|
99
|
+
return self
|
|
100
|
+
|
|
101
|
+
def subplot(self, row=None, col=None):
|
|
102
|
+
return _Plotext6Axes(self._figure.subplot(row, col))
|
|
103
|
+
|
|
104
|
+
def __getattr__(self, name):
|
|
105
|
+
return getattr(self._figure, name)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def create_plotext_figure(nrows: int = 1, ncols: int = 1):
|
|
109
|
+
# Plotext 6 exposes the figure through its public API rather than the
|
|
110
|
+
# removed private ``plotext._figure._figure_class``. It is a singleton,
|
|
111
|
+
# so reset it before handing it to maxplotlib as a fresh canvas.
|
|
112
|
+
figure = _Plotext6Axes(_plotext_figure.clear())
|
|
113
|
+
if nrows > 1 or ncols > 1:
|
|
114
|
+
figure.subplots(nrows, ncols)
|
|
115
|
+
return figure
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class PlotextFigure:
|
|
119
|
+
def __init__(self, figure: Any, suptitle: str | None = None):
|
|
120
|
+
self.figure = figure
|
|
121
|
+
self.suptitle = suptitle
|
|
122
|
+
|
|
123
|
+
def build(self, keep_colors: bool = True) -> str:
|
|
124
|
+
output = str(self.figure.build())
|
|
125
|
+
if self.suptitle:
|
|
126
|
+
output = f"{self.suptitle}\n{output}"
|
|
127
|
+
return output if keep_colors else strip_ansi(output)
|
|
128
|
+
|
|
129
|
+
def show(self) -> str:
|
|
130
|
+
output = self.build()
|
|
131
|
+
print(output)
|
|
132
|
+
return output
|
|
133
|
+
|
|
134
|
+
def savefig(self, path, append: bool = False, keep_colors: bool = False) -> None:
|
|
135
|
+
destination = Path(path)
|
|
136
|
+
mode = "a" if append else "w"
|
|
137
|
+
with destination.open(mode, encoding="utf-8") as handle:
|
|
138
|
+
handle.write(self.build(keep_colors=keep_colors))
|
|
139
|
+
handle.write("\n")
|
|
140
|
+
|
|
141
|
+
save_fig = savefig
|
|
142
|
+
|
|
143
|
+
def __getattr__(self, name):
|
|
144
|
+
return getattr(self.figure, name)
|
|
145
|
+
|
|
146
|
+
def __str__(self) -> str:
|
|
147
|
+
return self.build(keep_colors=False)
|