plopp 25.9.0__py3-none-any.whl → 25.10.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/toolbar.py +2 -2
- {plopp-25.9.0.dist-info → plopp-25.10.0.dist-info}/METADATA +1 -1
- {plopp-25.9.0.dist-info → plopp-25.10.0.dist-info}/RECORD +29 -26
- {plopp-25.9.0.dist-info → plopp-25.10.0.dist-info}/WHEEL +0 -0
- {plopp-25.9.0.dist-info → plopp-25.10.0.dist-info}/licenses/LICENSE +0 -0
- {plopp-25.9.0.dist-info → plopp-25.10.0.dist-info}/top_level.txt +0 -0
plopp/plotting/scatter3d.py
CHANGED
|
@@ -43,14 +43,20 @@ def scatter3d(
|
|
|
43
43
|
y: str = 'y',
|
|
44
44
|
z: str = 'z',
|
|
45
45
|
pos: str | None = None,
|
|
46
|
+
autoscale: bool = True,
|
|
47
|
+
camera: Camera | None = None,
|
|
48
|
+
cbar: bool = False,
|
|
49
|
+
clabel: str | None = None,
|
|
50
|
+
cmap: str = 'viridis',
|
|
51
|
+
cmax: sc.Variable | float = None,
|
|
52
|
+
cmin: sc.Variable | float = 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
|
-
cmap: str = 'viridis',
|
|
53
|
-
camera: Camera | None = None,
|
|
59
|
+
vmin: sc.Variable | float = None,
|
|
54
60
|
**kwargs,
|
|
55
61
|
) -> FigureLike:
|
|
56
62
|
"""Make a three-dimensional scatter plot.
|
|
@@ -76,20 +82,43 @@ def scatter3d(
|
|
|
76
82
|
The name of the coordinate that is to be used for the Z positions.
|
|
77
83
|
pos:
|
|
78
84
|
The name of the vector coordinate that is to be used for the positions.
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
autoscale:
|
|
86
|
+
Automatically scale the colormap on updates if ``True``.
|
|
87
|
+
camera:
|
|
88
|
+
Initial camera configuration (position, target).
|
|
89
|
+
cbar:
|
|
90
|
+
Show colorbar if ``True``. If ``cbar`` is ``True``, the marker will be colored
|
|
91
|
+
using the data values in the supplied data array.
|
|
92
|
+
clabel:
|
|
93
|
+
Label for colorscale (only applicable if ``cbar`` is ``True``).
|
|
94
|
+
cmap:
|
|
95
|
+
The colormap to be used for the colorscale (only applicable if ``cbar`` is
|
|
96
|
+
``True``).
|
|
97
|
+
cmax:
|
|
98
|
+
Upper limit for the colorscale (only applicable if ``cbar`` is ``True``).
|
|
99
|
+
cmin:
|
|
100
|
+
Lower limit for the colorscale (only applicable if ``cbar`` is ``True``).
|
|
81
101
|
figsize:
|
|
82
102
|
The size of the 3d rendering area, in pixels: ``(width, height)``.
|
|
103
|
+
logc:
|
|
104
|
+
Set to ``True`` for a logarithmic colorscale (only applicable if ``cbar`` is
|
|
105
|
+
``True``).
|
|
106
|
+
nan_color:
|
|
107
|
+
Color to use for NaN values in color mapping (only applicable if ``cbar`` is
|
|
108
|
+
``True``).
|
|
109
|
+
norm:
|
|
110
|
+
Set to ``'log'`` for a logarithmic colorscale (only applicable if ``cbar`` is
|
|
111
|
+
``True``). Legacy, prefer ``logc`` instead.
|
|
83
112
|
title:
|
|
84
113
|
The figure title.
|
|
85
114
|
vmin:
|
|
86
|
-
Lower
|
|
115
|
+
Lower limit for the colorscale for (only applicable if ``cbar`` is ``True``).
|
|
116
|
+
Legacy, prefer ``cmin`` instead.
|
|
87
117
|
vmax:
|
|
88
|
-
Upper
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Initial camera configuration (position, target).
|
|
118
|
+
Upper limit for the colorscale for (only applicable if ``cbar`` is ``True``).
|
|
119
|
+
Legacy, prefer ``cmax`` instead.
|
|
120
|
+
**kwargs:
|
|
121
|
+
All other kwargs are forwarded the underlying plotting library.
|
|
93
122
|
|
|
94
123
|
Returns
|
|
95
124
|
-------
|
|
@@ -115,14 +144,20 @@ def scatter3d(
|
|
|
115
144
|
x=x,
|
|
116
145
|
y=y,
|
|
117
146
|
z=z,
|
|
147
|
+
autoscale=autoscale,
|
|
148
|
+
camera=camera,
|
|
149
|
+
cbar=cbar,
|
|
150
|
+
clabel=clabel,
|
|
151
|
+
cmax=cmax,
|
|
152
|
+
cmin=cmin,
|
|
153
|
+
cmap=cmap,
|
|
118
154
|
figsize=figsize,
|
|
155
|
+
logc=logc,
|
|
156
|
+
nan_color=nan_color,
|
|
119
157
|
norm=norm,
|
|
120
158
|
title=title,
|
|
121
|
-
vmin=vmin,
|
|
122
159
|
vmax=vmax,
|
|
123
|
-
|
|
124
|
-
cbar=cbar,
|
|
125
|
-
camera=camera,
|
|
160
|
+
vmin=vmin,
|
|
126
161
|
**kwargs,
|
|
127
162
|
)
|
|
128
163
|
clip_planes = ClippingPlanes(fig)
|
plopp/plotting/slicer.py
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
from functools import partial
|
|
5
5
|
from itertools import groupby
|
|
6
|
+
from typing import Literal
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
import scipp as sc
|
|
8
9
|
|
|
9
10
|
from ..core import widget_node
|
|
10
11
|
from ..core.typing import FigureLike, PlottableMulti
|
|
11
12
|
from ..graphics import imagefigure, linefigure
|
|
12
13
|
from .common import (
|
|
14
|
+
categorize_args,
|
|
13
15
|
input_to_nodes,
|
|
14
16
|
preprocess,
|
|
15
17
|
raise_multiple_inputs_for_2d_plot_error,
|
|
@@ -34,19 +36,16 @@ class Slicer:
|
|
|
34
36
|
----------
|
|
35
37
|
obj:
|
|
36
38
|
The input data.
|
|
39
|
+
coords:
|
|
40
|
+
If supplied, use these coords instead of the input's dimension coordinates.
|
|
41
|
+
enable_player:
|
|
42
|
+
If ``True``, add a play button to the sliders to automatically step through
|
|
43
|
+
the slices.
|
|
37
44
|
keep:
|
|
38
45
|
The dimensions to be kept, all remaining dimensions will be sliced. This should
|
|
39
46
|
be a list of dims. If no dims are provided, the last dim will be kept in the
|
|
40
47
|
case of a 2-dimensional input, while the last two dims will be kept in the case
|
|
41
48
|
of higher dimensional inputs.
|
|
42
|
-
coords:
|
|
43
|
-
If supplied, use these coords instead of the input's dimension coordinates.
|
|
44
|
-
vmin:
|
|
45
|
-
The minimum value of the y-axis (1d plots) or color range (2d plots).
|
|
46
|
-
vmax:
|
|
47
|
-
The maximum value of the y-axis (1d plots) or color range (2d plots).
|
|
48
|
-
cbar:
|
|
49
|
-
Whether to display a colorbar for 2D plots.
|
|
50
49
|
**kwargs:
|
|
51
50
|
The additional arguments are forwarded to the underlying 1D or 2D figures.
|
|
52
51
|
"""
|
|
@@ -55,16 +54,14 @@ class Slicer:
|
|
|
55
54
|
self,
|
|
56
55
|
obj: PlottableMulti,
|
|
57
56
|
*,
|
|
58
|
-
keep: list[str] | None = None,
|
|
59
57
|
coords: list[str] | None = None,
|
|
60
|
-
vmin: VariableLike | float = None,
|
|
61
|
-
vmax: VariableLike | float = None,
|
|
62
|
-
cbar: bool = True,
|
|
63
58
|
enable_player: bool = False,
|
|
59
|
+
keep: list[str] | None = None,
|
|
64
60
|
**kwargs,
|
|
65
61
|
):
|
|
66
62
|
nodes = input_to_nodes(
|
|
67
|
-
obj,
|
|
63
|
+
obj,
|
|
64
|
+
processor=partial(preprocess, ignore_size=True, coords=coords),
|
|
68
65
|
)
|
|
69
66
|
|
|
70
67
|
dims = nodes[0]().dims
|
|
@@ -106,34 +103,60 @@ class Slicer:
|
|
|
106
103
|
self.slider_node = widget_node(self.slider)
|
|
107
104
|
self.slice_nodes = [slice_dims(node, self.slider_node) for node in nodes]
|
|
108
105
|
|
|
106
|
+
args = categorize_args(**kwargs)
|
|
107
|
+
|
|
109
108
|
ndims = len(keep)
|
|
110
109
|
if ndims == 1:
|
|
111
|
-
make_figure = linefigure
|
|
110
|
+
make_figure = partial(linefigure, **args['1d'])
|
|
112
111
|
elif ndims == 2:
|
|
113
112
|
if len(self.slice_nodes) > 1:
|
|
114
113
|
raise_multiple_inputs_for_2d_plot_error(origin='slicer')
|
|
115
|
-
make_figure = partial(imagefigure,
|
|
114
|
+
make_figure = partial(imagefigure, **args['2d'])
|
|
116
115
|
else:
|
|
117
116
|
raise ValueError(
|
|
118
117
|
f'Slicer plot: the number of dims to be kept must be 1 or 2, '
|
|
119
118
|
f'but {ndims} were requested.'
|
|
120
119
|
)
|
|
121
120
|
|
|
122
|
-
self.figure = make_figure(*self.slice_nodes
|
|
121
|
+
self.figure = make_figure(*self.slice_nodes)
|
|
123
122
|
require_interactive_figure(self.figure, 'slicer')
|
|
124
123
|
self.figure.bottom_bar.add(self.slider)
|
|
125
124
|
|
|
126
125
|
|
|
127
126
|
def slicer(
|
|
128
127
|
obj: PlottableMulti,
|
|
129
|
-
*,
|
|
130
128
|
keep: list[str] | None = None,
|
|
129
|
+
*,
|
|
130
|
+
aspect: Literal['auto', 'equal', None] = None,
|
|
131
131
|
autoscale: bool = True,
|
|
132
|
-
coords: list[str] | None = None,
|
|
133
|
-
vmin: VariableLike | float = None,
|
|
134
|
-
vmax: VariableLike | float = None,
|
|
135
132
|
cbar: bool = True,
|
|
133
|
+
clabel: str | None = None,
|
|
134
|
+
cmap: str = 'viridis',
|
|
135
|
+
cmax: sc.Variable | float | None = None,
|
|
136
|
+
cmin: sc.Variable | float | None = None,
|
|
137
|
+
coords: list[str] | None = None,
|
|
136
138
|
enable_player: bool = False,
|
|
139
|
+
errorbars: bool = True,
|
|
140
|
+
figsize: tuple[float, float] | None = None,
|
|
141
|
+
grid: bool = False,
|
|
142
|
+
legend: bool | tuple[float, float] = True,
|
|
143
|
+
logc: bool | None = None,
|
|
144
|
+
logx: bool | None = None,
|
|
145
|
+
logy: bool | None = None,
|
|
146
|
+
mask_cmap: str = 'gray',
|
|
147
|
+
mask_color: str | None = None,
|
|
148
|
+
nan_color: str | None = None,
|
|
149
|
+
norm: Literal['linear', 'log', None] = None,
|
|
150
|
+
scale: dict[str, str] | None = None,
|
|
151
|
+
title: str | None = None,
|
|
152
|
+
vmax: sc.Variable | float | None = None,
|
|
153
|
+
vmin: sc.Variable | float | None = None,
|
|
154
|
+
xlabel: str | None = None,
|
|
155
|
+
xmax: sc.Variable | float | None = None,
|
|
156
|
+
xmin: sc.Variable | float | None = None,
|
|
157
|
+
ylabel: str | None = None,
|
|
158
|
+
ymax: sc.Variable | float | None = None,
|
|
159
|
+
ymin: sc.Variable | float | None = None,
|
|
137
160
|
**kwargs,
|
|
138
161
|
) -> FigureLike:
|
|
139
162
|
"""
|
|
@@ -145,36 +168,110 @@ def slicer(
|
|
|
145
168
|
obj:
|
|
146
169
|
The object to be plotted.
|
|
147
170
|
keep:
|
|
148
|
-
The
|
|
149
|
-
be a
|
|
150
|
-
|
|
151
|
-
|
|
171
|
+
The single dimension to be kept, all remaining dimensions will be sliced.
|
|
172
|
+
This should be a single string. If no dim is provided, the last/inner dim will
|
|
173
|
+
be kept.
|
|
174
|
+
aspect:
|
|
175
|
+
Aspect ratio for the axes.
|
|
152
176
|
autoscale:
|
|
153
|
-
Automatically
|
|
154
|
-
|
|
177
|
+
Automatically scale the axes/colormap on updates if ``True``.
|
|
178
|
+
cbar:
|
|
179
|
+
Show colorbar in 2d plots if ``True``.
|
|
180
|
+
clabel:
|
|
181
|
+
Label for colorscale (2d plots only).
|
|
182
|
+
cmap:
|
|
183
|
+
The colormap to be used for the colorscale (2d plots only).
|
|
184
|
+
cmax:
|
|
185
|
+
Upper limit for colorscale (2d plots only).
|
|
186
|
+
cmin:
|
|
187
|
+
Lower limit for colorscale (2d plots only).
|
|
155
188
|
coords:
|
|
156
189
|
If supplied, use these coords instead of the input's dimension coordinates.
|
|
157
|
-
vmin:
|
|
158
|
-
The minimum value of the y-axis (1d plots) or color range (2d plots).
|
|
159
|
-
vmax:
|
|
160
|
-
The maximum value of the y-axis (1d plots) or color range (2d plots).
|
|
161
|
-
cbar:
|
|
162
|
-
Whether to display a colorbar for 2D plots.
|
|
163
190
|
enable_player:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
191
|
+
If ``True``, add a play button to the sliders to automatically step through
|
|
192
|
+
the slices.
|
|
193
|
+
errorbars:
|
|
194
|
+
Show errorbars in 1d plots if ``True``.
|
|
195
|
+
figsize:
|
|
196
|
+
The width and height of the figure, in inches.
|
|
197
|
+
grid:
|
|
198
|
+
Show grid if ``True``.
|
|
199
|
+
legend:
|
|
200
|
+
Show legend if ``True``. If ``legend`` is a tuple, it should contain the
|
|
201
|
+
``(x, y)`` coordinates of the legend's anchor point in axes coordinates.
|
|
202
|
+
logc:
|
|
203
|
+
If ``True``, use logarithmic scale for colorscale (2d plots only).
|
|
204
|
+
logx:
|
|
205
|
+
If ``True``, use logarithmic scale for x-axis.
|
|
206
|
+
logy:
|
|
207
|
+
If ``True``, use logarithmic scale for y-axis.
|
|
208
|
+
mask_cmap:
|
|
209
|
+
Colormap to use for masks in 2d plots.
|
|
210
|
+
mask_color:
|
|
211
|
+
Color of masks.
|
|
212
|
+
nan_color:
|
|
213
|
+
Color to use for NaN values in 2d plots.
|
|
214
|
+
norm:
|
|
215
|
+
Set to ``'log'`` for a logarithmic y-axis (1d plots) or logarithmic colorscale
|
|
216
|
+
(2d plots). Legacy, prefer ``logy`` and ``logc`` instead.
|
|
217
|
+
scale:
|
|
218
|
+
Change axis scaling between ``log`` and ``linear``. For example, specify
|
|
219
|
+
``scale={'time': 'log'}`` if you want log-scale for the ``time`` dimension.
|
|
220
|
+
Legacy, prefer ``logx`` and ``logy`` instead.
|
|
221
|
+
title:
|
|
222
|
+
The figure title.
|
|
223
|
+
vmax:
|
|
224
|
+
Upper limit for data to be displayed (y-axis for 1d plots, colorscale for
|
|
225
|
+
2d plots). Legacy, prefer ``ymax`` and ``cmax`` instead.
|
|
226
|
+
vmin:
|
|
227
|
+
Lower limit for data to be displayed (y-axis for 1d plots, colorscale for
|
|
228
|
+
2d plots). Legacy, prefer ``ymin`` and ``cmin`` instead.
|
|
229
|
+
xlabel:
|
|
230
|
+
Label for x-axis.
|
|
231
|
+
xmax:
|
|
232
|
+
Upper limit for x-axis.
|
|
233
|
+
xmin:
|
|
234
|
+
Lower limit for x-axis.
|
|
235
|
+
ylabel:
|
|
236
|
+
Label for y-axis.
|
|
237
|
+
ymax:
|
|
238
|
+
Upper limit for y-axis.
|
|
239
|
+
ymin:
|
|
240
|
+
Lower limit for y-axis.
|
|
167
241
|
**kwargs:
|
|
168
|
-
|
|
242
|
+
Additional arguments forwarded to the underlying plotting library.
|
|
169
243
|
"""
|
|
170
244
|
return Slicer(
|
|
171
245
|
obj,
|
|
172
246
|
keep=keep,
|
|
247
|
+
aspect=aspect,
|
|
173
248
|
autoscale=autoscale,
|
|
174
|
-
vmin=vmin,
|
|
175
|
-
vmax=vmax,
|
|
176
|
-
coords=coords,
|
|
177
249
|
cbar=cbar,
|
|
250
|
+
clabel=clabel,
|
|
251
|
+
cmap=cmap,
|
|
252
|
+
cmax=cmax,
|
|
253
|
+
cmin=cmin,
|
|
254
|
+
coords=coords,
|
|
178
255
|
enable_player=enable_player,
|
|
256
|
+
errorbars=errorbars,
|
|
257
|
+
figsize=figsize,
|
|
258
|
+
grid=grid,
|
|
259
|
+
legend=legend,
|
|
260
|
+
logc=logc,
|
|
261
|
+
logx=logx,
|
|
262
|
+
logy=logy,
|
|
263
|
+
mask_color=mask_color,
|
|
264
|
+
nan_color=nan_color,
|
|
265
|
+
norm=norm,
|
|
266
|
+
scale=scale,
|
|
267
|
+
title=title,
|
|
268
|
+
vmax=vmax,
|
|
269
|
+
vmin=vmin,
|
|
270
|
+
xlabel=xlabel,
|
|
271
|
+
xmax=xmax,
|
|
272
|
+
xmin=xmin,
|
|
273
|
+
ylabel=ylabel,
|
|
274
|
+
ymax=ymax,
|
|
275
|
+
ymin=ymin,
|
|
179
276
|
**kwargs,
|
|
180
277
|
).figure
|
plopp/plotting/superplot.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
2
|
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
|
|
3
3
|
|
|
4
|
+
from typing import Literal
|
|
5
|
+
|
|
6
|
+
import scipp as sc
|
|
4
7
|
|
|
5
8
|
from ..core.typing import FigureLike, Plottable
|
|
6
9
|
from .slicer import Slicer
|
|
@@ -9,6 +12,29 @@ from .slicer import Slicer
|
|
|
9
12
|
def superplot(
|
|
10
13
|
obj: Plottable,
|
|
11
14
|
keep: str | None = None,
|
|
15
|
+
*,
|
|
16
|
+
aspect: Literal['auto', 'equal', None] = None,
|
|
17
|
+
autoscale: bool = True,
|
|
18
|
+
coords: list[str] | None = None,
|
|
19
|
+
enable_player: bool = False,
|
|
20
|
+
errorbars: bool = True,
|
|
21
|
+
figsize: tuple[float, float] | None = None,
|
|
22
|
+
grid: bool = False,
|
|
23
|
+
legend: bool | tuple[float, float] = True,
|
|
24
|
+
logx: bool | None = None,
|
|
25
|
+
logy: bool | None = None,
|
|
26
|
+
mask_color: str = 'black',
|
|
27
|
+
norm: Literal['linear', 'log', None] = None,
|
|
28
|
+
scale: dict[str, str] | None = None,
|
|
29
|
+
title: str | None = None,
|
|
30
|
+
vmax: sc.Variable | float | None = None,
|
|
31
|
+
vmin: sc.Variable | float | None = None,
|
|
32
|
+
xlabel: str | None = None,
|
|
33
|
+
xmax: sc.Variable | float | None = None,
|
|
34
|
+
xmin: sc.Variable | float | None = None,
|
|
35
|
+
ylabel: str | None = None,
|
|
36
|
+
ymax: sc.Variable | float | None = None,
|
|
37
|
+
ymin: sc.Variable | float | None = None,
|
|
12
38
|
**kwargs,
|
|
13
39
|
) -> FigureLike:
|
|
14
40
|
"""
|
|
@@ -25,8 +51,56 @@ def superplot(
|
|
|
25
51
|
The single dimension to be kept, all remaining dimensions will be sliced.
|
|
26
52
|
This should be a single string. If no dim is provided, the last/inner dim will
|
|
27
53
|
be kept.
|
|
54
|
+
aspect:
|
|
55
|
+
Aspect ratio for the axes.
|
|
56
|
+
autoscale:
|
|
57
|
+
Automatically scale the axes/colormap if ``True``.
|
|
58
|
+
coords:
|
|
59
|
+
If supplied, use these coords instead of the input's dimension coordinates.
|
|
60
|
+
enable_player:
|
|
61
|
+
If ``True``, add a play button to the sliders to automatically step through
|
|
62
|
+
the slices.
|
|
63
|
+
errorbars:
|
|
64
|
+
Show errorbars in 1d plots if ``True``.
|
|
65
|
+
figsize:
|
|
66
|
+
The width and height of the figure, in inches.
|
|
67
|
+
grid:
|
|
68
|
+
Show grid if ``True``.
|
|
69
|
+
legend:
|
|
70
|
+
Show legend if ``True``. If ``legend`` is a tuple, it should contain the
|
|
71
|
+
``(x, y)`` coordinates of the legend's anchor point in axes coordinates.
|
|
72
|
+
logx:
|
|
73
|
+
If ``True``, use logarithmic scale for x-axis.
|
|
74
|
+
logy:
|
|
75
|
+
If ``True``, use logarithmic scale for y-axis.
|
|
76
|
+
mask_color:
|
|
77
|
+
Color of masks in 1d plots.
|
|
78
|
+
norm:
|
|
79
|
+
Set to ``'log'`` for a logarithmic y-axis. Legacy, prefer ``logy`` instead.
|
|
80
|
+
scale:
|
|
81
|
+
Change axis scaling between ``log`` and ``linear``. For example, specify
|
|
82
|
+
``scale={'time': 'log'}`` if you want log-scale for the ``time`` dimension.
|
|
83
|
+
Legacy, prefer ``logx`` instead.
|
|
84
|
+
title:
|
|
85
|
+
The figure title.
|
|
86
|
+
vmax:
|
|
87
|
+
Upper limit for data to be displayed (y-axis). Legacy, prefer ``ymax`` instead.
|
|
88
|
+
vmin:
|
|
89
|
+
Lower limit for data to be displayed (y-axis). Legacy, prefer ``ymin`` instead.
|
|
90
|
+
xlabel:
|
|
91
|
+
Label for x-axis.
|
|
92
|
+
xmax:
|
|
93
|
+
Upper limit for x-axis.
|
|
94
|
+
xmin:
|
|
95
|
+
Lower limit for x-axis.
|
|
96
|
+
ylabel:
|
|
97
|
+
Label for y-axis.
|
|
98
|
+
ymax:
|
|
99
|
+
Upper limit for y-axis.
|
|
100
|
+
ymin:
|
|
101
|
+
Lower limit for y-axis.
|
|
28
102
|
**kwargs:
|
|
29
|
-
|
|
103
|
+
Additional arguments forwarded to the underlying plotting library.
|
|
30
104
|
|
|
31
105
|
Returns
|
|
32
106
|
-------
|
|
@@ -36,7 +110,33 @@ def superplot(
|
|
|
36
110
|
"""
|
|
37
111
|
from ..widgets import LineSaveTool
|
|
38
112
|
|
|
39
|
-
slicer = Slicer(
|
|
113
|
+
slicer = Slicer(
|
|
114
|
+
obj,
|
|
115
|
+
keep=keep,
|
|
116
|
+
aspect=aspect,
|
|
117
|
+
autoscale=autoscale,
|
|
118
|
+
coords=coords,
|
|
119
|
+
enable_player=enable_player,
|
|
120
|
+
errorbars=errorbars,
|
|
121
|
+
figsize=figsize,
|
|
122
|
+
grid=grid,
|
|
123
|
+
legend=legend,
|
|
124
|
+
logx=logx,
|
|
125
|
+
logy=logy,
|
|
126
|
+
mask_color=mask_color,
|
|
127
|
+
norm=norm,
|
|
128
|
+
scale=scale,
|
|
129
|
+
title=title,
|
|
130
|
+
vmax=vmax,
|
|
131
|
+
vmin=vmin,
|
|
132
|
+
xlabel=xlabel,
|
|
133
|
+
xmax=xmax,
|
|
134
|
+
xmin=xmin,
|
|
135
|
+
ylabel=ylabel,
|
|
136
|
+
ymax=ymax,
|
|
137
|
+
ymin=ymin,
|
|
138
|
+
**kwargs,
|
|
139
|
+
)
|
|
40
140
|
slicer.figure.right_bar.add(
|
|
41
141
|
LineSaveTool(
|
|
42
142
|
data_node=slicer.slice_nodes[0],
|
plopp/plotting/xyplot.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
2
|
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
|
|
3
3
|
|
|
4
|
+
from typing import Literal
|
|
4
5
|
|
|
5
6
|
import scipp as sc
|
|
6
7
|
from numpy import ndarray
|
|
@@ -39,6 +40,25 @@ def _make_data_array(x: sc.Variable, y: sc.Variable) -> sc.DataArray:
|
|
|
39
40
|
def xyplot(
|
|
40
41
|
x: sc.Variable | ndarray | list | Node,
|
|
41
42
|
y: sc.Variable | ndarray | list | Node,
|
|
43
|
+
aspect: Literal['auto', 'equal', None] = None,
|
|
44
|
+
autoscale: bool = True,
|
|
45
|
+
errorbars: bool = True,
|
|
46
|
+
figsize: tuple[float, float] | None = None,
|
|
47
|
+
grid: bool = False,
|
|
48
|
+
legend: bool | tuple[float, float] = True,
|
|
49
|
+
logx: bool | None = None,
|
|
50
|
+
logy: bool | None = None,
|
|
51
|
+
norm: Literal['linear', 'log', None] = None,
|
|
52
|
+
scale: dict[str, str] | None = None,
|
|
53
|
+
title: str | None = None,
|
|
54
|
+
vmax: sc.Variable | float | None = None,
|
|
55
|
+
vmin: sc.Variable | float | None = None,
|
|
56
|
+
xlabel: str | None = None,
|
|
57
|
+
xmax: sc.Variable | float | None = None,
|
|
58
|
+
xmin: sc.Variable | float | None = None,
|
|
59
|
+
ylabel: str | None = None,
|
|
60
|
+
ymax: sc.Variable | float | None = None,
|
|
61
|
+
ymin: sc.Variable | float | None = None,
|
|
42
62
|
**kwargs,
|
|
43
63
|
) -> FigureLike:
|
|
44
64
|
"""
|
|
@@ -53,9 +73,72 @@ def xyplot(
|
|
|
53
73
|
Must be one-dimensional.
|
|
54
74
|
y:
|
|
55
75
|
The variable to use as the data for the vertical axis. Must be one-dimensional.
|
|
76
|
+
aspect:
|
|
77
|
+
Aspect ratio for the axes.
|
|
78
|
+
autoscale:
|
|
79
|
+
Automatically scale the axes on updates if ``True``.
|
|
80
|
+
errorbars:
|
|
81
|
+
Show errorbars in 1d plots if ``True``.
|
|
82
|
+
figsize:
|
|
83
|
+
The width and height of the figure, in inches.
|
|
84
|
+
grid:
|
|
85
|
+
Show grid if ``True``.
|
|
86
|
+
legend:
|
|
87
|
+
Show legend if ``True``. If ``legend`` is a tuple, it should contain the
|
|
88
|
+
``(x, y)`` coordinates of the legend's anchor point in axes coordinates.
|
|
89
|
+
logx:
|
|
90
|
+
If ``True``, use logarithmic scale for x-axis.
|
|
91
|
+
logy:
|
|
92
|
+
If ``True``, use logarithmic scale for y-axis.
|
|
93
|
+
norm:
|
|
94
|
+
Set to ``'log'`` for a logarithmic y-axis. Legacy, prefer ``logy`` instead.
|
|
95
|
+
scale:
|
|
96
|
+
Change axis scaling between ``log`` and ``linear``. For example, specify
|
|
97
|
+
``scale={'time': 'log'}`` if you want log-scale for the ``time`` dimension.
|
|
98
|
+
Legacy, prefer ``logx`` instead.
|
|
99
|
+
title:
|
|
100
|
+
The figure title.
|
|
101
|
+
vmax:
|
|
102
|
+
Upper limit for data to be displayed (y-axis). Legacy, prefer ``ymax`` instead.
|
|
103
|
+
vmin:
|
|
104
|
+
Lower limit for data to be displayed (y-axis). Legacy, prefer ``ymin`` instead.
|
|
105
|
+
xlabel:
|
|
106
|
+
Label for x-axis.
|
|
107
|
+
xmax:
|
|
108
|
+
Upper limit for x-axis.
|
|
109
|
+
xmin:
|
|
110
|
+
Lower limit for x-axis.
|
|
111
|
+
ylabel:
|
|
112
|
+
Label for y-axis.
|
|
113
|
+
ymax:
|
|
114
|
+
Upper limit for y-axis.
|
|
115
|
+
ymin:
|
|
116
|
+
Lower limit for y-axis.
|
|
56
117
|
**kwargs:
|
|
57
|
-
|
|
118
|
+
All other kwargs are forwarded the underlying plotting library.
|
|
58
119
|
"""
|
|
59
120
|
x = Node(to_variable, x)
|
|
60
121
|
y = Node(to_variable, y)
|
|
61
|
-
return linefigure(
|
|
122
|
+
return linefigure(
|
|
123
|
+
Node(_make_data_array, x=x, y=y),
|
|
124
|
+
aspect=aspect,
|
|
125
|
+
autoscale=autoscale,
|
|
126
|
+
errorbars=errorbars,
|
|
127
|
+
figsize=figsize,
|
|
128
|
+
grid=grid,
|
|
129
|
+
legend=legend,
|
|
130
|
+
logx=logx,
|
|
131
|
+
logy=logy,
|
|
132
|
+
norm=norm,
|
|
133
|
+
scale=scale,
|
|
134
|
+
title=title,
|
|
135
|
+
vmax=vmax,
|
|
136
|
+
vmin=vmin,
|
|
137
|
+
xlabel=xlabel,
|
|
138
|
+
xmax=xmax,
|
|
139
|
+
xmin=xmin,
|
|
140
|
+
ylabel=ylabel,
|
|
141
|
+
ymax=ymax,
|
|
142
|
+
ymin=ymin,
|
|
143
|
+
**kwargs,
|
|
144
|
+
)
|
plopp/utils/__init__.py
ADDED
plopp/utils/__init__.pyi
ADDED
plopp/utils/arg_parse.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
# Copyright (c) 2025 Scipp contributors (https://github.com/scipp)
|
|
3
|
+
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def parse_mutually_exclusive(**kwargs) -> Any | None:
|
|
8
|
+
"""
|
|
9
|
+
Check that only one of the provided keyword arguments is not None.
|
|
10
|
+
Return that one.
|
|
11
|
+
Additionally, if the final value is a string (either 'linear' or 'log'), return a
|
|
12
|
+
boolean indicating whether the value is 'log'.
|
|
13
|
+
"""
|
|
14
|
+
values = list(kwargs.values())
|
|
15
|
+
if None not in values:
|
|
16
|
+
raise ValueError(f'Only one of {list(kwargs.keys())} can be specified.')
|
|
17
|
+
out = ([v for v in values if v is not None] or [None])[0]
|
|
18
|
+
match out:
|
|
19
|
+
case 'linear':
|
|
20
|
+
return False
|
|
21
|
+
case 'log':
|
|
22
|
+
return True
|
|
23
|
+
case _:
|
|
24
|
+
return out
|
plopp/widgets/toolbar.py
CHANGED
|
@@ -60,12 +60,12 @@ def make_toolbar_canvas2d(view: GraphicalView) -> Toolbar:
|
|
|
60
60
|
"""
|
|
61
61
|
|
|
62
62
|
def logx() -> None:
|
|
63
|
-
view.canvas.
|
|
63
|
+
view.canvas.toggle_logx()
|
|
64
64
|
view.autoscale()
|
|
65
65
|
view.canvas.draw()
|
|
66
66
|
|
|
67
67
|
def logy() -> None:
|
|
68
|
-
view.canvas.
|
|
68
|
+
view.canvas.toggle_logy()
|
|
69
69
|
view.autoscale()
|
|
70
70
|
view.canvas.draw()
|
|
71
71
|
|