plopp 25.9.0__py3-none-any.whl → 25.11.0__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.
- plopp/backends/matplotlib/canvas.py +89 -8
- plopp/backends/matplotlib/line.py +3 -1
- plopp/backends/matplotlib/scatter.py +2 -2
- plopp/backends/plotly/canvas.py +73 -8
- plopp/backends/pythreejs/canvas.py +22 -0
- plopp/backends/pythreejs/mesh3d.py +1 -0
- plopp/backends/pythreejs/scatter3d.py +3 -0
- plopp/core/node_class.py +23 -0
- plopp/graphics/colormapper.py +153 -55
- plopp/graphics/graphicalview.py +70 -21
- plopp/plotting/common.py +71 -3
- plopp/plotting/inspector.py +110 -6
- plopp/plotting/mesh3d.py +49 -16
- plopp/plotting/plot.py +106 -44
- plopp/plotting/scatter.py +125 -34
- plopp/plotting/scatter3d.py +52 -17
- plopp/plotting/slicer.py +137 -40
- plopp/plotting/superplot.py +102 -2
- plopp/plotting/xyplot.py +85 -2
- plopp/utils/__init__.py +6 -0
- plopp/utils/__init__.pyi +7 -0
- plopp/utils/arg_parse.py +24 -0
- plopp/{utils.py → utils/deprecation.py} +0 -3
- plopp/widgets/drawing.py +10 -3
- plopp/widgets/toolbar.py +2 -2
- {plopp-25.9.0.dist-info → plopp-25.11.0.dist-info}/METADATA +2 -1
- {plopp-25.9.0.dist-info → plopp-25.11.0.dist-info}/RECORD +30 -27
- {plopp-25.9.0.dist-info → plopp-25.11.0.dist-info}/WHEEL +0 -0
- {plopp-25.9.0.dist-info → plopp-25.11.0.dist-info}/licenses/LICENSE +0 -0
- {plopp-25.9.0.dist-info → plopp-25.11.0.dist-info}/top_level.txt +0 -0
plopp/plotting/inspector.py
CHANGED
|
@@ -38,9 +38,31 @@ def inspector(
|
|
|
38
38
|
obj: Plottable,
|
|
39
39
|
dim: str | None = None,
|
|
40
40
|
*,
|
|
41
|
+
aspect: Literal['auto', 'equal', None] = None,
|
|
42
|
+
autoscale: bool = True,
|
|
43
|
+
cbar: bool = True,
|
|
44
|
+
clabel: str | None = None,
|
|
45
|
+
cmax: sc.Variable | float | None = None,
|
|
46
|
+
cmin: sc.Variable | float | None = None,
|
|
47
|
+
errorbars: bool = True,
|
|
48
|
+
figsize: tuple[float, float] | None = None,
|
|
49
|
+
grid: bool = False,
|
|
50
|
+
legend: bool | tuple[float, float] = True,
|
|
51
|
+
logc: bool | None = None,
|
|
52
|
+
logy: bool | None = None,
|
|
53
|
+
mask_cmap: str = 'gray',
|
|
54
|
+
mask_color: str = 'black',
|
|
55
|
+
nan_color: str | None = None,
|
|
56
|
+
norm: Literal['linear', 'log', None] = None,
|
|
41
57
|
operation: Literal['sum', 'mean', 'min', 'max'] = 'sum',
|
|
42
58
|
orientation: Literal['horizontal', 'vertical'] = 'horizontal',
|
|
43
|
-
|
|
59
|
+
title: str | None = None,
|
|
60
|
+
vmax: sc.Variable | float | None = None,
|
|
61
|
+
vmin: sc.Variable | float | None = None,
|
|
62
|
+
xlabel: str | None = None,
|
|
63
|
+
ylabel: str | None = None,
|
|
64
|
+
ymax: sc.Variable | float | None = None,
|
|
65
|
+
ymin: sc.Variable | float | None = None,
|
|
44
66
|
**kwargs,
|
|
45
67
|
):
|
|
46
68
|
"""
|
|
@@ -66,16 +88,65 @@ def inspector(
|
|
|
66
88
|
the dimension that remains in the one-dimensional slices generated by adding
|
|
67
89
|
markers on the image. If no dim is provided, the last (inner) dim of the input
|
|
68
90
|
data will be used.
|
|
91
|
+
aspect:
|
|
92
|
+
Aspect ratio for the axes.
|
|
93
|
+
autoscale:
|
|
94
|
+
Automatically scale the axes/colormap on updates if ``True``.
|
|
95
|
+
cbar:
|
|
96
|
+
Show colorbar if ``True`` (2d figure).
|
|
97
|
+
clabel:
|
|
98
|
+
Label for colorscale (2d figure).
|
|
99
|
+
cmax:
|
|
100
|
+
Upper limit for colorscale (2d figure).
|
|
101
|
+
cmin:
|
|
102
|
+
Lower limit for colorscale (2d figure).
|
|
103
|
+
errorbars:
|
|
104
|
+
Show errorbars if ``True`` (1d figure).
|
|
105
|
+
figsize:
|
|
106
|
+
The width and height of the figure, in inches.
|
|
107
|
+
grid:
|
|
108
|
+
Show grid if ``True``.
|
|
109
|
+
legend:
|
|
110
|
+
Show legend if ``True``. If ``legend`` is a tuple, it should contain the
|
|
111
|
+
``(x, y)`` coordinates of the legend's anchor point in axes coordinates
|
|
112
|
+
(1d figure).
|
|
113
|
+
logc:
|
|
114
|
+
If ``True``, use logarithmic scale for colorscale (2d figure).
|
|
115
|
+
logy:
|
|
116
|
+
If ``True``, use logarithmic scale for y-axis (1d figure).
|
|
117
|
+
mask_cmap:
|
|
118
|
+
Colormap to use for masks in 2d figure.
|
|
119
|
+
mask_color:
|
|
120
|
+
Color of masks (overrides ``mask_cmap``).
|
|
121
|
+
nan_color:
|
|
122
|
+
Color to use for NaN values in 2d figure.
|
|
123
|
+
norm:
|
|
124
|
+
Set to ``'log'`` for a logarithmic y-axis (1d figure) or logarithmic colorscale
|
|
125
|
+
(2d figure). Legacy, prefer ``logy`` and ``logc`` instead.
|
|
69
126
|
operation:
|
|
70
127
|
The operation to apply along the third (undisplayed) dimension specified by
|
|
71
128
|
``dim``.
|
|
72
129
|
orientation:
|
|
73
130
|
Display the two panels side-by-side ('horizontal') or one below the other
|
|
74
131
|
('vertical').
|
|
75
|
-
|
|
76
|
-
|
|
132
|
+
title:
|
|
133
|
+
The figure title.
|
|
134
|
+
vmax:
|
|
135
|
+
Upper limit for data to be displayed (y-axis for 1d figure, colorscale for
|
|
136
|
+
2d figure). Legacy, prefer ``ymax`` and ``cmax`` instead.
|
|
137
|
+
vmin:
|
|
138
|
+
Lower limit for data to be displayed (y-axis for 1d figure, colorscale for
|
|
139
|
+
2d figure). Legacy, prefer ``ymin`` and ``cmin`` instead.
|
|
140
|
+
xlabel:
|
|
141
|
+
Label for x-axis (2d figure).
|
|
142
|
+
ylabel:
|
|
143
|
+
Label for y-axis (2d figure).
|
|
144
|
+
ymax:
|
|
145
|
+
Upper limit for y-axis (1d figure).
|
|
146
|
+
ymin:
|
|
147
|
+
Lower limit for y-axis (1d figure).
|
|
77
148
|
**kwargs:
|
|
78
|
-
|
|
149
|
+
Additional arguments forwarded to the underlying plotting library.
|
|
79
150
|
|
|
80
151
|
Returns
|
|
81
152
|
-------
|
|
@@ -83,7 +154,19 @@ def inspector(
|
|
|
83
154
|
A :class:`Box` which will contain two :class:`Figure` and one slider widget.
|
|
84
155
|
"""
|
|
85
156
|
|
|
86
|
-
f1d = linefigure(
|
|
157
|
+
f1d = linefigure(
|
|
158
|
+
autoscale=autoscale,
|
|
159
|
+
errorbars=errorbars,
|
|
160
|
+
grid=grid,
|
|
161
|
+
legend=legend,
|
|
162
|
+
logy=logy,
|
|
163
|
+
mask_color=mask_color,
|
|
164
|
+
norm=norm,
|
|
165
|
+
vmax=vmax,
|
|
166
|
+
vmin=vmin,
|
|
167
|
+
ymax=ymax,
|
|
168
|
+
ymin=ymin,
|
|
169
|
+
)
|
|
87
170
|
require_interactive_figure(f1d, 'inspector')
|
|
88
171
|
|
|
89
172
|
in_node = Node(preprocess, obj, ignore_size=True)
|
|
@@ -97,7 +180,28 @@ def inspector(
|
|
|
97
180
|
dim = data.dims[-1]
|
|
98
181
|
bin_edges_node = Node(_to_bin_edges, in_node, dim=dim)
|
|
99
182
|
op_node = Node(_apply_op, da=bin_edges_node, op=operation, dim=dim)
|
|
100
|
-
f2d = imagefigure(
|
|
183
|
+
f2d = imagefigure(
|
|
184
|
+
op_node,
|
|
185
|
+
aspect=aspect,
|
|
186
|
+
cbar=cbar,
|
|
187
|
+
clabel=clabel,
|
|
188
|
+
cmax=cmax,
|
|
189
|
+
cmin=cmin,
|
|
190
|
+
figsize=figsize,
|
|
191
|
+
grid=grid,
|
|
192
|
+
logc=logc,
|
|
193
|
+
mask_color=mask_color,
|
|
194
|
+
nan_color=nan_color,
|
|
195
|
+
norm=norm,
|
|
196
|
+
title=title,
|
|
197
|
+
vmax=vmax,
|
|
198
|
+
vmin=vmin,
|
|
199
|
+
xlabel=xlabel,
|
|
200
|
+
ylabel=ylabel,
|
|
201
|
+
ymax=ymax,
|
|
202
|
+
ymin=ymin,
|
|
203
|
+
**kwargs,
|
|
204
|
+
)
|
|
101
205
|
|
|
102
206
|
from ..widgets import Box, PointsTool
|
|
103
207
|
|
plopp/plotting/mesh3d.py
CHANGED
|
@@ -39,17 +39,24 @@ def _preprocess_mesh(
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def mesh3d(
|
|
42
|
+
*,
|
|
42
43
|
vertices: Plottable,
|
|
43
44
|
faces: Plottable,
|
|
44
45
|
vertexcolors: Plottable | None = None,
|
|
46
|
+
autoscale: bool = True,
|
|
47
|
+
camera: Camera | None = None,
|
|
48
|
+
clabel: str | None = None,
|
|
49
|
+
cmap: str = 'viridis',
|
|
50
|
+
cmax: sc.Variable | float = None,
|
|
51
|
+
cmin: sc.Variable | float = None,
|
|
45
52
|
edgecolor: str | None = None,
|
|
46
53
|
figsize: tuple[int, int] = (600, 400),
|
|
47
|
-
|
|
54
|
+
logc: bool | None = None,
|
|
55
|
+
nan_color: str | None = None,
|
|
56
|
+
norm: Literal['linear', 'log', None] = None,
|
|
48
57
|
title: str | None = None,
|
|
49
|
-
vmin: sc.Variable | float = None,
|
|
50
58
|
vmax: sc.Variable | float = None,
|
|
51
|
-
|
|
52
|
-
camera: Camera | None = None,
|
|
59
|
+
vmin: sc.Variable | float = None,
|
|
53
60
|
**kwargs,
|
|
54
61
|
) -> FigureLike:
|
|
55
62
|
"""
|
|
@@ -66,22 +73,42 @@ def mesh3d(
|
|
|
66
73
|
vertexcolors:
|
|
67
74
|
The colors of the vertices of the mesh. If ``None``, the mesh will have a
|
|
68
75
|
single solid color.
|
|
76
|
+
autoscale:
|
|
77
|
+
Automatically scale the colormap on updates if ``True``.
|
|
78
|
+
camera:
|
|
79
|
+
Initial camera configuration (position, target).
|
|
80
|
+
clabel:
|
|
81
|
+
Label for colorscale (only applicable if ``cbar`` is ``True``).
|
|
82
|
+
cmap:
|
|
83
|
+
The colormap to be used for the colorscale (only applicable if ``cbar`` is
|
|
84
|
+
``True``).
|
|
85
|
+
cmax:
|
|
86
|
+
Upper limit for the colorscale (only applicable if ``cbar`` is ``True``).
|
|
87
|
+
cmin:
|
|
88
|
+
Lower limit for the colorscale (only applicable if ``cbar`` is ``True``).
|
|
69
89
|
edgecolor:
|
|
70
90
|
The color of the edges. If None, no edges are drawn.
|
|
71
91
|
figsize:
|
|
72
|
-
The size of the
|
|
92
|
+
The size of the 3d rendering area, in pixels: ``(width, height)``.
|
|
93
|
+
logc:
|
|
94
|
+
Set to ``True`` for a logarithmic colorscale (only applicable if ``cbar`` is
|
|
95
|
+
``True``).
|
|
96
|
+
nan_color:
|
|
97
|
+
Color to use for NaN values in color mapping (only applicable if ``cbar`` is
|
|
98
|
+
``True``).
|
|
73
99
|
norm:
|
|
74
|
-
|
|
100
|
+
Set to ``'log'`` for a logarithmic colorscale (only applicable if ``cbar`` is
|
|
101
|
+
``True``). Legacy, prefer ``logc`` instead.
|
|
75
102
|
title:
|
|
76
|
-
The title
|
|
103
|
+
The figure title.
|
|
77
104
|
vmin:
|
|
78
|
-
|
|
105
|
+
Lower limit for the colorscale for (only applicable if ``cbar`` is ``True``).
|
|
106
|
+
Legacy, prefer ``cmin`` instead.
|
|
79
107
|
vmax:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
The camera configuration.
|
|
108
|
+
Upper limit for the colorscale for (only applicable if ``cbar`` is ``True``).
|
|
109
|
+
Legacy, prefer ``cmax`` instead.
|
|
110
|
+
**kwargs:
|
|
111
|
+
All other kwargs are forwarded the underlying plotting library.
|
|
85
112
|
"""
|
|
86
113
|
from ..graphics import mesh3dfigure
|
|
87
114
|
|
|
@@ -95,14 +122,20 @@ def mesh3d(
|
|
|
95
122
|
fig = mesh3dfigure(
|
|
96
123
|
input_node,
|
|
97
124
|
vertexcolors=vertexcolors,
|
|
125
|
+
autoscale=autoscale,
|
|
126
|
+
camera=camera,
|
|
127
|
+
clabel=clabel,
|
|
128
|
+
cmax=cmax,
|
|
129
|
+
cmin=cmin,
|
|
130
|
+
cmap=cmap,
|
|
98
131
|
edgecolor=edgecolor,
|
|
99
132
|
figsize=figsize,
|
|
133
|
+
logc=logc,
|
|
134
|
+
nan_color=nan_color,
|
|
100
135
|
norm=norm,
|
|
101
136
|
title=title,
|
|
102
|
-
vmin=vmin,
|
|
103
137
|
vmax=vmax,
|
|
104
|
-
|
|
105
|
-
camera=camera,
|
|
138
|
+
vmin=vmin,
|
|
106
139
|
**kwargs,
|
|
107
140
|
)
|
|
108
141
|
return fig
|
plopp/plotting/plot.py
CHANGED
|
@@ -4,30 +4,51 @@
|
|
|
4
4
|
from functools import partial
|
|
5
5
|
from typing import Literal
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import scipp as sc
|
|
8
8
|
|
|
9
9
|
from ..core.typing import FigureLike, PlottableMulti
|
|
10
10
|
from ..graphics import imagefigure, linefigure
|
|
11
|
-
from .common import
|
|
11
|
+
from .common import (
|
|
12
|
+
categorize_args,
|
|
13
|
+
input_to_nodes,
|
|
14
|
+
preprocess,
|
|
15
|
+
raise_multiple_inputs_for_2d_plot_error,
|
|
16
|
+
)
|
|
12
17
|
|
|
13
18
|
|
|
14
19
|
def plot(
|
|
15
20
|
obj: PlottableMulti,
|
|
16
21
|
*,
|
|
17
22
|
aspect: Literal['auto', 'equal', None] = None,
|
|
23
|
+
autoscale: bool = True,
|
|
18
24
|
cbar: bool = True,
|
|
25
|
+
clabel: str | None = None,
|
|
26
|
+
cmap: str = 'viridis',
|
|
27
|
+
cmax: sc.Variable | float | None = None,
|
|
28
|
+
cmin: sc.Variable | float | None = None,
|
|
19
29
|
coords: list[str] | None = None,
|
|
20
30
|
errorbars: bool = True,
|
|
21
31
|
figsize: tuple[float, float] | None = None,
|
|
22
32
|
grid: bool = False,
|
|
23
33
|
ignore_size: bool = False,
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
legend: bool | tuple[float, float] = True,
|
|
35
|
+
logc: bool | None = None,
|
|
36
|
+
logx: bool | None = None,
|
|
37
|
+
logy: bool | None = None,
|
|
38
|
+
mask_cmap: str = 'gray',
|
|
39
|
+
mask_color: str | None = None,
|
|
40
|
+
nan_color: str | None = None,
|
|
41
|
+
norm: Literal['linear', 'log', None] = None,
|
|
26
42
|
scale: dict[str, str] | None = None,
|
|
27
43
|
title: str | None = None,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
vmax: sc.Variable | float | None = None,
|
|
45
|
+
vmin: sc.Variable | float | None = None,
|
|
46
|
+
xlabel: str | None = None,
|
|
47
|
+
xmax: sc.Variable | float | None = None,
|
|
48
|
+
xmin: sc.Variable | float | None = None,
|
|
49
|
+
ylabel: str | None = None,
|
|
50
|
+
ymax: sc.Variable | float | None = None,
|
|
51
|
+
ymin: sc.Variable | float | None = None,
|
|
31
52
|
**kwargs,
|
|
32
53
|
) -> FigureLike:
|
|
33
54
|
"""Plot a Scipp object.
|
|
@@ -38,8 +59,18 @@ def plot(
|
|
|
38
59
|
The object to be plotted.
|
|
39
60
|
aspect:
|
|
40
61
|
Aspect ratio for the axes.
|
|
62
|
+
autoscale:
|
|
63
|
+
Automatically scale the axes/colormap on updates if ``True``.
|
|
41
64
|
cbar:
|
|
42
65
|
Show colorbar in 2d plots if ``True``.
|
|
66
|
+
clabel:
|
|
67
|
+
Label for colorscale (2d plots only).
|
|
68
|
+
cmap:
|
|
69
|
+
The colormap to be used for the colorscale (2d plots only).
|
|
70
|
+
cmax:
|
|
71
|
+
Upper limit for colorscale (2d plots only).
|
|
72
|
+
cmin:
|
|
73
|
+
Lower limit for colorscale (2d plots only).
|
|
43
74
|
coords:
|
|
44
75
|
If supplied, use these coords instead of the input's dimension coordinates.
|
|
45
76
|
errorbars:
|
|
@@ -49,34 +80,51 @@ def plot(
|
|
|
49
80
|
grid:
|
|
50
81
|
Show grid if ``True``.
|
|
51
82
|
ignore_size:
|
|
52
|
-
If ``True``, skip the check that prevents the rendering of very large data
|
|
53
|
-
|
|
83
|
+
If ``True``, skip the check that prevents the rendering of very large data.
|
|
84
|
+
legend:
|
|
85
|
+
Show legend if ``True``. If ``legend`` is a tuple, it should contain the
|
|
86
|
+
``(x, y)`` coordinates of the legend's anchor point in axes coordinates.
|
|
87
|
+
logc:
|
|
88
|
+
If ``True``, use logarithmic scale for colorscale (2d plots only).
|
|
89
|
+
logx:
|
|
90
|
+
If ``True``, use logarithmic scale for x-axis.
|
|
91
|
+
logy:
|
|
92
|
+
If ``True``, use logarithmic scale for y-axis.
|
|
93
|
+
mask_cmap:
|
|
94
|
+
Colormap to use for masks in 2d plots.
|
|
54
95
|
mask_color:
|
|
55
|
-
Color of masks
|
|
96
|
+
Color of masks.
|
|
97
|
+
nan_color:
|
|
98
|
+
Color to use for NaN values in 2d plots.
|
|
56
99
|
norm:
|
|
57
100
|
Set to ``'log'`` for a logarithmic y-axis (1d plots) or logarithmic colorscale
|
|
58
|
-
(2d plots).
|
|
101
|
+
(2d plots). Legacy, prefer ``logy`` and ``logc`` instead.
|
|
59
102
|
scale:
|
|
60
103
|
Change axis scaling between ``log`` and ``linear``. For example, specify
|
|
61
|
-
``scale={'
|
|
104
|
+
``scale={'time': 'log'}`` if you want log-scale for the ``time`` dimension.
|
|
105
|
+
Legacy, prefer ``logx`` and ``logy`` instead.
|
|
62
106
|
title:
|
|
63
107
|
The figure title.
|
|
64
|
-
vmin:
|
|
65
|
-
Lower bound for data to be displayed (y-axis for 1d plots, colorscale for
|
|
66
|
-
2d plots).
|
|
67
108
|
vmax:
|
|
68
|
-
Upper
|
|
69
|
-
2d plots).
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
109
|
+
Upper limit for data to be displayed (y-axis for 1d plots, colorscale for
|
|
110
|
+
2d plots). Legacy, prefer ``ymax`` and ``cmax`` instead.
|
|
111
|
+
vmin:
|
|
112
|
+
Lower limit for data to be displayed (y-axis for 1d plots, colorscale for
|
|
113
|
+
2d plots). Legacy, prefer ``ymin`` and ``cmin`` instead.
|
|
114
|
+
xlabel:
|
|
115
|
+
Label for x-axis.
|
|
116
|
+
xmax:
|
|
117
|
+
Upper limit for x-axis.
|
|
118
|
+
xmin:
|
|
119
|
+
Lower limit for x-axis.
|
|
120
|
+
ylabel:
|
|
121
|
+
Label for y-axis.
|
|
122
|
+
ymax:
|
|
123
|
+
Upper limit for y-axis.
|
|
124
|
+
ymin:
|
|
125
|
+
Lower limit for y-axis.
|
|
73
126
|
**kwargs:
|
|
74
|
-
All other kwargs are
|
|
75
|
-
library. The underlying functions called are the following:
|
|
76
|
-
|
|
77
|
-
- 1d data with a non bin-edge coordinate: ``plot``
|
|
78
|
-
- 1d data with a bin-edge coordinate: ``step``
|
|
79
|
-
- 2d data: ``pcolormesh``
|
|
127
|
+
All other kwargs are forwarded to the underlying plotting library.
|
|
80
128
|
|
|
81
129
|
Returns
|
|
82
130
|
-------
|
|
@@ -84,17 +132,37 @@ def plot(
|
|
|
84
132
|
A figure.
|
|
85
133
|
"""
|
|
86
134
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
135
|
+
args = categorize_args(
|
|
136
|
+
aspect=aspect,
|
|
137
|
+
autoscale=autoscale,
|
|
138
|
+
cbar=cbar,
|
|
139
|
+
clabel=clabel,
|
|
140
|
+
cmap=cmap,
|
|
141
|
+
cmax=cmax,
|
|
142
|
+
cmin=cmin,
|
|
143
|
+
errorbars=errorbars,
|
|
144
|
+
figsize=figsize,
|
|
145
|
+
grid=grid,
|
|
146
|
+
legend=legend,
|
|
147
|
+
logc=logc,
|
|
148
|
+
logx=logx,
|
|
149
|
+
logy=logy,
|
|
150
|
+
mask_cmap=mask_cmap,
|
|
151
|
+
mask_color=mask_color,
|
|
152
|
+
nan_color=nan_color,
|
|
153
|
+
norm=norm,
|
|
154
|
+
scale=scale,
|
|
155
|
+
title=title,
|
|
156
|
+
vmax=vmax,
|
|
157
|
+
vmin=vmin,
|
|
158
|
+
xlabel=xlabel,
|
|
159
|
+
xmax=xmax,
|
|
160
|
+
xmin=xmin,
|
|
161
|
+
ylabel=ylabel,
|
|
162
|
+
ymax=ymax,
|
|
163
|
+
ymin=ymin,
|
|
96
164
|
**kwargs,
|
|
97
|
-
|
|
165
|
+
)
|
|
98
166
|
|
|
99
167
|
nodes = input_to_nodes(
|
|
100
168
|
obj, processor=partial(preprocess, ignore_size=ignore_size, coords=coords)
|
|
@@ -110,17 +178,11 @@ def plot(
|
|
|
110
178
|
)
|
|
111
179
|
ndim = ndims.pop()
|
|
112
180
|
if ndim == 1:
|
|
113
|
-
return linefigure(
|
|
114
|
-
*nodes,
|
|
115
|
-
errorbars=errorbars,
|
|
116
|
-
mask_color=mask_color,
|
|
117
|
-
legend=legend,
|
|
118
|
-
**common_args,
|
|
119
|
-
)
|
|
181
|
+
return linefigure(*nodes, **args['1d'])
|
|
120
182
|
elif ndim == 2:
|
|
121
183
|
if len(nodes) > 1:
|
|
122
184
|
raise_multiple_inputs_for_2d_plot_error(origin='plot')
|
|
123
|
-
return imagefigure(*nodes,
|
|
185
|
+
return imagefigure(*nodes, **args['2d'])
|
|
124
186
|
else:
|
|
125
187
|
raise ValueError(
|
|
126
188
|
'The plot function can only plot 1d and 2d data, got input '
|
plopp/plotting/scatter.py
CHANGED
|
@@ -8,26 +8,33 @@ from typing import Literal
|
|
|
8
8
|
import scipp as sc
|
|
9
9
|
|
|
10
10
|
from ..core.typing import FigureLike, PlottableMulti
|
|
11
|
-
from .common import check_not_binned, from_compatible_lib, input_to_nodes
|
|
11
|
+
from .common import check_not_binned, check_size, from_compatible_lib, input_to_nodes
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def _preprocess_scatter(
|
|
15
15
|
obj: PlottableMulti,
|
|
16
16
|
x: str,
|
|
17
17
|
y: str,
|
|
18
|
+
pos: str | None,
|
|
18
19
|
size: str | None,
|
|
19
20
|
name: str | None = None,
|
|
21
|
+
ignore_size: bool = False,
|
|
20
22
|
):
|
|
21
23
|
da = from_compatible_lib(obj)
|
|
22
24
|
check_not_binned(da)
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
if pos is not None:
|
|
27
|
+
coords = {k: getattr(da.coords[pos].fields, k) for k in (x, y)}
|
|
28
|
+
else:
|
|
29
|
+
coords = {k: da.coords[k] for k in (x, y)}
|
|
30
|
+
|
|
25
31
|
if isinstance(size, str):
|
|
26
|
-
|
|
27
|
-
coords = {k: da.coords[k] for k in cnames}
|
|
32
|
+
coords[size] = da.coords[size]
|
|
28
33
|
out = sc.DataArray(data=da.data, masks=da.masks, coords=coords)
|
|
29
34
|
if out.ndim != 1:
|
|
30
35
|
out = out.flatten(to=uuid.uuid4().hex)
|
|
36
|
+
if not ignore_size:
|
|
37
|
+
check_size(out)
|
|
31
38
|
if name is not None:
|
|
32
39
|
out.name = name
|
|
33
40
|
return out
|
|
@@ -38,15 +45,35 @@ def scatter(
|
|
|
38
45
|
*,
|
|
39
46
|
x: str = 'x',
|
|
40
47
|
y: str = 'y',
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
vmax: sc.Variable | float = None,
|
|
47
|
-
cbar: bool = False,
|
|
48
|
+
pos: str | None = None,
|
|
49
|
+
aspect: Literal['auto', 'equal', None] = None,
|
|
50
|
+
autoscale: bool = True,
|
|
51
|
+
cbar: bool = True,
|
|
52
|
+
clabel: str | None = None,
|
|
48
53
|
cmap: str = 'viridis',
|
|
54
|
+
cmax: sc.Variable | float | None = None,
|
|
55
|
+
cmin: sc.Variable | float | None = None,
|
|
56
|
+
figsize: tuple[float, float] | None = None,
|
|
57
|
+
grid: bool = False,
|
|
58
|
+
ignore_size: bool = False,
|
|
49
59
|
legend: bool | tuple[float, float] = True,
|
|
60
|
+
logc: bool | None = None,
|
|
61
|
+
logx: bool | None = None,
|
|
62
|
+
logy: bool | None = None,
|
|
63
|
+
mask_color: str = 'black',
|
|
64
|
+
nan_color: str | None = None,
|
|
65
|
+
norm: Literal['linear', 'log', None] = None,
|
|
66
|
+
scale: dict[str, str] | None = None,
|
|
67
|
+
size: str | float | None = None,
|
|
68
|
+
title: str | None = None,
|
|
69
|
+
vmax: sc.Variable | float | None = None,
|
|
70
|
+
vmin: sc.Variable | float | None = None,
|
|
71
|
+
xlabel: str | None = None,
|
|
72
|
+
xmax: sc.Variable | float | None = None,
|
|
73
|
+
xmin: sc.Variable | float | None = None,
|
|
74
|
+
ylabel: str | None = None,
|
|
75
|
+
ymax: sc.Variable | float | None = None,
|
|
76
|
+
ymin: sc.Variable | float | None = None,
|
|
50
77
|
**kwargs,
|
|
51
78
|
) -> FigureLike:
|
|
52
79
|
"""
|
|
@@ -62,50 +89,114 @@ def scatter(
|
|
|
62
89
|
The name of the coordinate that is to be used for the X positions.
|
|
63
90
|
y:
|
|
64
91
|
The name of the coordinate that is to be used for the Y positions.
|
|
65
|
-
|
|
66
|
-
The
|
|
67
|
-
|
|
68
|
-
|
|
92
|
+
pos:
|
|
93
|
+
The name of the vector coordinate that is to be used for the positions.
|
|
94
|
+
aspect:
|
|
95
|
+
Aspect ratio for the axes.
|
|
96
|
+
autoscale:
|
|
97
|
+
Automatically scale the axes/colormap if ``True``.
|
|
98
|
+
cbar:
|
|
99
|
+
Show colorbar if ``True``. If ``cbar`` is ``True``, the marker will be colored
|
|
100
|
+
using the data values in the supplied data array.
|
|
101
|
+
clabel:
|
|
102
|
+
Label for colorscale (only applicable if ``cbar`` is ``True``).
|
|
103
|
+
cmap:
|
|
104
|
+
The colormap to be used for the colorscale (only applicable if ``cbar`` is
|
|
105
|
+
``True``).
|
|
106
|
+
cmax:
|
|
107
|
+
Upper limit for the colorscale (only applicable if ``cbar`` is ``True``).
|
|
108
|
+
cmin:
|
|
109
|
+
Lower limit for the colorscale (only applicable if ``cbar`` is ``True``).
|
|
69
110
|
figsize:
|
|
70
111
|
The width and height of the figure, in inches.
|
|
112
|
+
grid:
|
|
113
|
+
Show grid if ``True``.
|
|
114
|
+
ignore_size:
|
|
115
|
+
If ``True``, skip the check that prevents the rendering of very large data.
|
|
116
|
+
legend:
|
|
117
|
+
Show legend if ``True``. If ``legend`` is a tuple, it should contain the
|
|
118
|
+
``(x, y)`` coordinates of the legend's anchor point in axes coordinates.
|
|
119
|
+
logc:
|
|
120
|
+
Set to ``True`` for a logarithmic colorscale (only applicable if ``cbar`` is
|
|
121
|
+
``True``).
|
|
122
|
+
logx:
|
|
123
|
+
If ``True``, use logarithmic scale for x-axis.
|
|
124
|
+
logy:
|
|
125
|
+
If ``True``, use logarithmic scale for y-axis.
|
|
126
|
+
mask_color:
|
|
127
|
+
Color of markers for masked data.
|
|
128
|
+
nan_color:
|
|
129
|
+
Color to use for NaN values in color mapping (only applicable if ``cbar`` is
|
|
130
|
+
``True``).
|
|
71
131
|
norm:
|
|
72
132
|
Set to ``'log'`` for a logarithmic colorscale (only applicable if ``cbar`` is
|
|
73
|
-
``True``).
|
|
133
|
+
``True``). Legacy, prefer ``logc`` instead.
|
|
134
|
+
scale:
|
|
135
|
+
Change axis scaling between ``log`` and ``linear``. For example, specify
|
|
136
|
+
``scale={'time': 'log'}`` if you want log-scale for the ``time`` dimension.
|
|
137
|
+
Legacy, prefer ``logx`` and ``logy`` instead.
|
|
74
138
|
title:
|
|
75
139
|
The figure title.
|
|
76
140
|
vmin:
|
|
77
|
-
Lower
|
|
141
|
+
Lower limit for the colorscale for (only applicable if ``cbar`` is ``True``).
|
|
142
|
+
Legacy, prefer ``cmin`` instead.
|
|
78
143
|
vmax:
|
|
79
|
-
Upper
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
144
|
+
Upper limit for the colorscale for (only applicable if ``cbar`` is ``True``).
|
|
145
|
+
Legacy, prefer ``cmax`` instead.
|
|
146
|
+
xlabel:
|
|
147
|
+
Label for x-axis.
|
|
148
|
+
xmax:
|
|
149
|
+
Upper limit for x-axis.
|
|
150
|
+
xmin:
|
|
151
|
+
Lower limit for x-axis.
|
|
152
|
+
ylabel:
|
|
153
|
+
Label for y-axis.
|
|
154
|
+
ymax:
|
|
155
|
+
Upper limit for y-axis.
|
|
156
|
+
ymin:
|
|
157
|
+
Lower limit for y-axis.
|
|
88
158
|
**kwargs:
|
|
89
159
|
All other kwargs are forwarded the underlying plotting library.
|
|
90
160
|
"""
|
|
91
161
|
from ..graphics import scatterfigure
|
|
92
162
|
|
|
93
163
|
nodes = input_to_nodes(
|
|
94
|
-
obj,
|
|
164
|
+
obj,
|
|
165
|
+
processor=partial(
|
|
166
|
+
_preprocess_scatter, x=x, y=y, pos=pos, size=size, ignore_size=ignore_size
|
|
167
|
+
),
|
|
95
168
|
)
|
|
96
169
|
|
|
97
170
|
return scatterfigure(
|
|
98
171
|
*nodes,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
172
|
+
aspect=aspect,
|
|
173
|
+
autoscale=autoscale,
|
|
174
|
+
cbar=cbar,
|
|
175
|
+
clabel=clabel,
|
|
176
|
+
cmap=cmap,
|
|
177
|
+
cmax=cmax,
|
|
178
|
+
cmin=cmin,
|
|
102
179
|
figsize=figsize,
|
|
180
|
+
grid=grid,
|
|
181
|
+
legend=legend,
|
|
182
|
+
logc=logc,
|
|
183
|
+
logx=logx,
|
|
184
|
+
logy=logy,
|
|
185
|
+
mask_color=mask_color,
|
|
186
|
+
nan_color=nan_color,
|
|
103
187
|
norm=norm,
|
|
188
|
+
scale=scale,
|
|
189
|
+
size=size,
|
|
104
190
|
title=title,
|
|
105
|
-
vmin=vmin,
|
|
106
191
|
vmax=vmax,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
192
|
+
vmin=vmin,
|
|
193
|
+
x=x,
|
|
194
|
+
xlabel=xlabel,
|
|
195
|
+
xmax=xmax,
|
|
196
|
+
xmin=xmin,
|
|
197
|
+
y=y,
|
|
198
|
+
ylabel=ylabel,
|
|
199
|
+
ymax=ymax,
|
|
200
|
+
ymin=ymin,
|
|
110
201
|
**kwargs,
|
|
111
202
|
)
|