plotpress 0.23.2__py3-none-any.whl
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.
- plotpress/__init__.py +108 -0
- plotpress/_interactive.py +2849 -0
- plotpress/_spectral.py +154 -0
- plotpress/_version.py +1 -0
- plotpress/artists.py +1382 -0
- plotpress/axes.py +3221 -0
- plotpress/colors.py +498 -0
- plotpress/figure.py +3084 -0
- plotpress/fonts/__init__.py +51 -0
- plotpress/fonts/families.py +192 -0
- plotpress/fonts/installed.py +82 -0
- plotpress/fonts/metrics.py +265 -0
- plotpress/png.py +93 -0
- plotpress/polar.py +240 -0
- plotpress/primitives.py +335 -0
- plotpress/qt.py +427 -0
- plotpress/raster.py +1316 -0
- plotpress/style.py +91 -0
- plotpress/svg.py +2589 -0
- plotpress/ticker.py +212 -0
- plotpress/transform.py +85 -0
- plotpress/vega.py +1324 -0
- plotpress/vega_lite.py +1199 -0
- plotpress-0.23.2.dist-info/METADATA +378 -0
- plotpress-0.23.2.dist-info/RECORD +28 -0
- plotpress-0.23.2.dist-info/WHEEL +5 -0
- plotpress-0.23.2.dist-info/licenses/LICENSE +21 -0
- plotpress-0.23.2.dist-info/top_level.txt +1 -0
plotpress/__init__.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""plotpress -- a fast, figure-centric, SVG-first plotting library.
|
|
2
|
+
|
|
3
|
+
Distinct from matplotlib in three ways:
|
|
4
|
+
|
|
5
|
+
1. **No global state.** There is no ``pyplot``, no "current figure/axes", no
|
|
6
|
+
global ``rcParams``. Everything hangs off a :class:`Figure`, which owns its
|
|
7
|
+
own :class:`Style`. Build a plot, and the figure holds everything it needs to
|
|
8
|
+
render itself.
|
|
9
|
+
2. **matplotlib-like API.** ``Figure``/``Axes`` and methods like ``plot``,
|
|
10
|
+
``scatter``, ``pcolormesh``, ``set_xlabel``, ``legend`` mirror matplotlib so
|
|
11
|
+
existing code is easy to port. ``plotpress.subplots(...)`` returns
|
|
12
|
+
``(fig, axes)`` just like ``plt.subplots(...)`` -- minus the globals.
|
|
13
|
+
3. **SVG-first + fast.** Output is vector SVG (with embedded raster only for
|
|
14
|
+
mesh/image layers), optionally interactive. The hot paths are vectorized in
|
|
15
|
+
NumPy and huge lines are decimated, so it is fast in **pure Python** -- no
|
|
16
|
+
compiled extension, installs everywhere pip does.
|
|
17
|
+
|
|
18
|
+
Example
|
|
19
|
+
-------
|
|
20
|
+
>>> import plotpress
|
|
21
|
+
>>> fig, ax = plotpress.subplots()
|
|
22
|
+
>>> ax.plot([0, 1, 2], [0, 1, 4], label="quadratic")
|
|
23
|
+
>>> ax.legend()
|
|
24
|
+
>>> fig.save("out.svg")
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
import importlib
|
|
28
|
+
|
|
29
|
+
# name -> (submodule, attribute). Every one of these pulls in NumPy
|
|
30
|
+
# transitively (through .colors or .figure), which is most of what
|
|
31
|
+
# `import plotpress` costs. Resolving them lazily on first access -- rather
|
|
32
|
+
# than importing eagerly here -- keeps a bare `import plotpress` cheap for
|
|
33
|
+
# callers who only need __version__ or are introspecting the package.
|
|
34
|
+
_LAZY_ATTRS = {
|
|
35
|
+
"Figure": (".figure", "Figure"),
|
|
36
|
+
"subplots": (".figure", "subplots"),
|
|
37
|
+
"subplots_from_layout": (".figure", "subplots_from_layout"),
|
|
38
|
+
"Report": (".figure", "Report"),
|
|
39
|
+
"load_data": (".figure", "load_data"),
|
|
40
|
+
"load_data_xarray": (".figure", "load_data_xarray"),
|
|
41
|
+
"select_panel": (".figure", "select_panel"),
|
|
42
|
+
"Style": (".style", "Style"),
|
|
43
|
+
"Normalize": (".colors", "Normalize"),
|
|
44
|
+
"LogNorm": (".colors", "LogNorm"),
|
|
45
|
+
"PowerNorm": (".colors", "PowerNorm"),
|
|
46
|
+
"SymLogNorm": (".colors", "SymLogNorm"),
|
|
47
|
+
"get_cmap": (".colors", "get_cmap"),
|
|
48
|
+
"available_colormaps": (".colors", "available_colormaps"),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def __getattr__(name):
|
|
53
|
+
try:
|
|
54
|
+
module_name, attr_name = _LAZY_ATTRS[name]
|
|
55
|
+
except KeyError:
|
|
56
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from None
|
|
57
|
+
value = getattr(importlib.import_module(module_name, __name__), attr_name)
|
|
58
|
+
globals()[name] = value # cache: __getattr__ only runs once per name
|
|
59
|
+
return value
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def __dir__():
|
|
63
|
+
return sorted(__all__)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _detect_version() -> str:
|
|
67
|
+
"""The installed version, however this copy of plotpress is being run.
|
|
68
|
+
|
|
69
|
+
Three cases, in order of precision. ``_version.py`` is written by
|
|
70
|
+
versioningit at build time and is the exact string the artifact was built
|
|
71
|
+
with. Failing that -- a source checkout that was never built, which is how
|
|
72
|
+
the test suite imports the package -- fall back to the metadata of an
|
|
73
|
+
installed copy. If neither exists, say so rather than inventing a number.
|
|
74
|
+
"""
|
|
75
|
+
try:
|
|
76
|
+
from ._version import __version__ as v
|
|
77
|
+
return v
|
|
78
|
+
except ImportError:
|
|
79
|
+
pass
|
|
80
|
+
try:
|
|
81
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
82
|
+
except ImportError: # pragma: no cover - Python < 3.8
|
|
83
|
+
return "0+unknown"
|
|
84
|
+
try:
|
|
85
|
+
return version("plotpress")
|
|
86
|
+
except PackageNotFoundError:
|
|
87
|
+
return "0+unknown"
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
__version__ = _detect_version()
|
|
91
|
+
|
|
92
|
+
__all__ = [
|
|
93
|
+
"Figure",
|
|
94
|
+
"subplots",
|
|
95
|
+
"subplots_from_layout",
|
|
96
|
+
"Report",
|
|
97
|
+
"load_data",
|
|
98
|
+
"load_data_xarray",
|
|
99
|
+
"select_panel",
|
|
100
|
+
"Style",
|
|
101
|
+
"Normalize",
|
|
102
|
+
"LogNorm",
|
|
103
|
+
"PowerNorm",
|
|
104
|
+
"SymLogNorm",
|
|
105
|
+
"get_cmap",
|
|
106
|
+
"available_colormaps",
|
|
107
|
+
"__version__",
|
|
108
|
+
]
|