Skip to content

exp_plot_manager

Plot Manager for the Experiment object

ExperimentPlotManager

ExperimentPlotManager scan.plot = ScanPlotManager(scan) scan.plot() # plot default axes scan.plot.plot(xaxis, yaxis) # creates figure scan.plot.plotline(xaxis, yaxis) # plots line on current figure scan.plot.image() # create figure and display detector image

Parameters:

Name Type Description Default
experiment Experiment

Experiment object

required
Source code in mmg_toolbox/plotting/exp_plot_manager.py
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
class ExperimentPlotManager:
    """
    ExperimentPlotManager
        scan.plot = ScanPlotManager(scan)
        scan.plot() # plot default axes
        scan.plot.plot(xaxis, yaxis)  # creates figure
        scan.plot.plotline(xaxis, yaxis)  # plots line on current figure
        scan.plot.image()  # create figure and display detector image

    :param experiment: Experiment object
    """
    set_plot_defaults = set_plot_defaults
    show = plt.show

    def __init__(self, experiment: Experiment):
        self.exp = experiment
        self._x_axis: str | None = None
        self._y_axis: str | None = None
        self._z_axis: str | None = None
        self._title: str | None = None

    def __call__(self, *args, **kwargs):
        return self.plot(*args, **kwargs)

    def _set_axes(self, x_axis: str | None = None, y_axis: str | None = None,
                  z_axis: str | None = None, title: str | None = None):
        self._x_axis = x_axis
        self._y_axis = y_axis
        self._z_axis = z_axis
        self._title = title

    def _set_axes_from_scans(self, *scans: ScanFile):
        if scans and hasattr(scans[0], 'plot'):
            self._x_axis = scans[0].plot._x_axis
            self._y_axis = scans[0].plot._y_axis
            self._z_axis = scans[0].plot._z_axis
            self._title = self.exp.generate_scans_title(*scans)

    def plot(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
             xaxis: str = 'axes', yaxis: str | list[str] = 'signal', axes: plt.Axes | None = None, **kwargs) -> plt.Axes:
        """
        Create matplotlib figure with a line plot from a or several scans

            axes = exp.plot.plot(file1, file2, xaxis='eta', yaxis='roi2_sum')

        :param scan_files: scan number or filename (multiple allowed)
        :param hdf_map: hdfmap object or None
        :param xaxis: str name or address of array to plot on x axis
        :param yaxis: str name or address of array to plot on y axis, also accepts list of names for multiple lines
        :param axes: matplotlib.axes subplot, or None to create a figure
        :param kwargs: given directly to plt.plot(..., **kwars)
        :return: axes object
        """
        scans = self.exp.scans(*scan_files, hdf_map=hdf_map)
        if axes is None:
            fig, axes = plt.subplots()
        for scan in scans:
            scan.plot.plot(xaxis, yaxis, axes=axes, **kwargs)
        if len(scan_files) > 1:
            axes.legend(scan_files)
        self._set_axes_from_scans(*scans)
        if self._title:
            axes.set_title(self._title)
        return axes

    def image(self,  scan_file: ScanFile = -1, hdf_map: hdfmap.NexusMap | None = None,
              index: int | tuple | slice | None = None, xaxis: str = 'axes',
              axes: plt.Axes | None = None, clim: tuple[float, float] | None = None,
              cmap: str = DEFAULT_CMAP, colorbar: bool = False, **kwargs) -> plt.Axes | None:
        """
        Plot image in matplotlib figure (if available)
        :param scan_file: scan number or filename
        :param hdf_map: hdfmap object or None
        :param index: int, detector image index, 0-length of scan, if None, use centre index
        :param xaxis: name or address of xaxis dataset
        :param axes: matplotlib axes to plot on (None to create figure)
        :param clim: [min, max] colormap cut-offs (None for auto)
        :param cmap: str colormap name (None for auto)
        :param colorbar: False/ True add colorbar to plot
        :param kwargs: additional arguments for plot_detector_image
        :return: axes object or None if no image
        """
        scan = self.exp.scans(scan_file, hdf_map=hdf_map)[0]
        if scan.map.image_data:
            ax = scan.plot.image(index, xaxis, axes, clim, cmap, colorbar, **kwargs)
            self._set_axes_from_scans(scan)
            return ax
        return None

    def detail(self, scan_file: ScanFile = -1, hdf_map: hdfmap.NexusMap | None = None,
               xaxis: str = 'axes', yaxis: str | list[str] = 'signal',
               index: int | tuple | slice | None = None, clim: tuple[float, float] | None = None,
               cmap: str = DEFAULT_CMAP, **kwargs) -> plt.Figure:
        """
        Create matplotlib figure with plot of the scan and detector image
        :param scan_file: scan number or filename
        :param hdf_map: hdfmap object or None
        :param xaxis: str name or address of array to plot on x axis
        :param yaxis: str name or address of array to plot on y axis, also accepts list of names for multiple plots
        :param index: int, detector image index, 0-length of scan, if None, use centre index
        :param clim: [min, max] colormap cut-offs (None for auto)
        :param cmap: str colormap name (None for auto)
        :param kwargs: given directly to plt.plot(..., *args, **kwars)
        :return: figure object
        """
        scan = self.exp.scans(scan_file, hdf_map=hdf_map)[0]

        # Create figure
        fig, ((lt, rt), (lb, rb)) = plt.subplots(2, 2, figsize=[FIG_SIZE[0] * 1.2, FIG_SIZE[1] * 1.2], dpi=FIG_DPI)
        fig.subplots_adjust(hspace=0.35, left=0.1, right=0.95)
        fig.suptitle(scan.title())

        # Top left - line plot
        scan.plot(xaxis, yaxis, axes=lt, **kwargs)
        self._set_axes_from_scans(scan)
        lt.set_title(None)

        # Top right - image plot
        if scan.map.image_data:
            scan.plot.image(index, xaxis, cmap=cmap, clim=clim, axes=rt)
            rt.set_title(None)

        # Bottom-Left - details
        details = self.exp.scan_str(scan_file, hdf_map=hdf_map)
        lb.text(-0.2, 1, details, ha='left', va='top', multialignment="left", fontsize=12, wrap=True)
        lb.set_axis_off()

        # Bottom-Right - fit results
        rb.set_axis_off()
        if 'fit' in yaxis:
            fit_report = str(scan.fit)
            rb.text(-0.2, 1, fit_report, ha='left', va='top', multialignment="left", fontsize=12, wrap=True)
        return fig

    def multi_lines(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
                    xaxis: str = 'axes', yaxis: str = 'signal', value: str | None = None,
                    axes: plt.Axes | None = None, **kwargs) -> plt.Axes:
        """
        Create matplotlib figure with a line plot from a or several scans

            axes = exp.plot.multi_lines(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

        :param scan_files: scan number or filename (multiple allowed)
        :param hdf_map: hdfmap object or None
        :param xaxis: str name or path of array to plot on x axis
        :param yaxis: str name or path of array to plot on y axis
        :param value: str name or path of float value to distinguish lines
        :param axes: matplotlib.axes subplot, or None to create a figure
        :param kwargs: given directly to plt.plot(..., **kwars)
        :return: axes object
        """
        scans = self.exp.scans(*scan_files, hdf_map=hdf_map)
        hdf_map = scans[0].map

        plot_data = []
        for scan in scans:
            with hdfmap.load_hdf(scan.filename) as hdf:
                xdata = hdf_map.eval(hdf, xaxis)
                ydata = hdf_map.eval(hdf, yaxis)
                value_data = np.mean(hdf_map.eval(hdf, value)) if value else None
                plot_data.append((value_data, xdata, ydata))

        if axes is None:
            fig, axes = plt.subplots()
        lines, sm = plot_lines(axes, *plot_data, **kwargs)

        x_lab, y_lab, value_label = hdf_map.generate_ids(xaxis, yaxis, value, modify_missing=False)
        axes.set_xlabel(x_lab)
        axes.set_ylabel(y_lab)
        axes.set_title(self.exp.generate_scans_title(*scan_files, hdf_map=hdf_map))
        self._set_axes_from_scans(*scans)

        plt.colorbar(sm, ax=axes, label=value_label)
        return axes

    def multi_plot(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
                   xaxis: str = 'axes', yaxis: str | list[str] = 'signal', value: str | None = None,
                   subplots: tuple[int, int] = (4, 4), **kwargs) ->  list[tuple[plt.Figure, plt.Axes]]:
        """
        Create matplotlib figure with a line plot from a or several scans

            axes = exp.plot.multi_plot(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

        :param scan_files: scan number or filename (multiple allowed)
        :param hdf_map: hdfmap object or None
        :param xaxis: str name or path of array to plot on x axis
        :param yaxis: str name or path of array to plot on y axis, or a list of names for multiple plots per axis
        :param value: str name or path of float value to distinguish lines
        :param subplots: [int, int] number of subplots per figure [vertical, horizontal]
        :param kwargs: given directly to plt.plot(..., **kwars)
        :return: list of figures
        """
        scans = self.exp.scans(*scan_files, hdf_map=hdf_map)
        ttl = self.exp.generate_scans_title(*scan_files)
        fig_ax = generate_subplots(len(scan_files), subplots=subplots, suptitle=ttl)

        for scan, (fig, ax) in zip(scans, fig_ax):
            scan.plot.plot(xaxis=xaxis, yaxis=yaxis, axes=ax, **kwargs)
            val = scan.format("\n%s = {%s}" % (value, value)) if value is not None else ""
            ttl_exp = scan.title() + val
            ax.set_title(ttl_exp)
        self._set_axes_from_scans(*scans)
        return fig_ax

    def multi_image(self,  *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
                    index: int | tuple | slice | None = None, xaxis: str = 'axes',
                    clim: tuple[float, float] | None = None, cmap: str = DEFAULT_CMAP,
                    colorbar: bool = False, **kwargs) -> list[tuple[plt.Figure, plt.Axes]]:
        """
        Plot scan images in matplotlib figure (if available)
        :param scan_files: scan number or filename (multiple allowed)
        :param hdf_map: hdfmap object or None
        :param index: int, detector image index, 0-length of scan, if None, use centre index
        :param xaxis: name or address of xaxis dataset
        :param clim: [min, max] colormap cut-offs (None for auto)
        :param cmap: str colormap name (None for auto)
        :param colorbar: False/ True add colorbar to plot
        :param kwargs: additional arguments for plot_detector_image
        :return: [(Figure, Axes)] for each scan
        """
        fig_axes = generate_subplots(len(scan_files))
        for scan, (fig, axes) in zip(scan_files, fig_axes):
            self.image(scan, axes=axes, hdf_map=hdf_map, index=index, xaxis=xaxis,
                       clim=clim, cmap=cmap, colorbar=colorbar, **kwargs)
        return fig_axes

    def surface_2d(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
                   xaxis: str = 'axes', signal: str = 'signal', values: str | None = None,
                   axes: plt.Axes | None = None, clim: tuple[float, float] | None = None,
                   axlim: str = 'image', **kwargs) -> plt.Axes:
        """
        Create matplotlib figure with a 2D image

            axes = exp.plot.surface_2d(*range(-10, 0), xaxis='eta', signal='roi2_sum', values='Tsample')

        :param scan_files: scan number or filename (multiple allowed)
        :param hdf_map: hdfmap object or None
        :param xaxis: str name or path of array to plot on x axis
        :param signal: str name or path of array to plot on z axis
        :param values: str name or path of float value to distinguish different scans
        :param axes: matplotlib.axes subplot, or None to create a figure
        :param clim: None or [min, max] values for color cutoff from plt.clim
        :param axlim: axis limits from plt.axis
        :param kwargs: given directly to plt.pcolormesh(..., **kwargs)
        :return: axes object
        """
        first_file = self.exp.get_scan_filename(scan_files[0])
        hdf_map = hdfmap.create_nexus_map(first_file) if hdf_map is None else hdf_map
        x, y, z = self.exp.generate_mesh(*scan_files, hdf_map=hdf_map,
                                         axes=xaxis, signal=signal, values=values)

        if axes is None:
            fig, axes = plt.subplots()
        surf = plot_2d_surface(axes=axes, image=z, xdata=x, ydata=y, clim=clim, axlim=axlim, **kwargs)
        ttl = self.exp.generate_scans_title(*scan_files)
        axes.set_title(ttl)

        x_lab, y_lab, value_label = hdf_map.generate_ids(xaxis, signal, values, modify_missing=False)
        axes.set_xlabel(x_lab)
        axes.set_ylabel(value_label)
        axes.figure.colorbar(surf, ax=axes, label=signal)
        self._set_axes(x_lab, y_lab, signal, ttl)
        return axes

    def lines_3d(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
                 xaxis: str = 'axes', signal: str = 'signal', values: str | None = None,
                 axes: Axes3D | None = None, legend: bool = False, **kwargs) -> Axes3D:
        """
        Create matplotlib figure with a 2D image

            axes = exp.plot.surface_2d(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

        :param scan_files: scan number or filename (multiple allowed)
        :param hdf_map: hdfmap object or None
        :param xaxis: str name or path of array to plot on x axis
        :param signal: str name or path of array to plot on z axis
        :param values: str name or path of float value to distinguish different scans
        :param axes: matplotlib.axes subplot, or None to create a figure
        :param legend: if True, adds a legend
        :param kwargs: given directly to plt.plot(..., **kwargs)
        :return: axes object
        """
        first_file = self.exp.get_scan_filename(scan_files[0])
        hdf_map = hdfmap.create_nexus_map(first_file) if hdf_map is None else hdf_map
        scans = self.exp.scans(*scan_files, hdf_map=hdf_map)
        data_fields = [signal, xaxis] + ([values] if values is not None else [])
        data = self.exp.join_scan_data(*scan_files, hdf_map=hdf_map, data_fields=data_fields)
        labels = [scan.label() for scan in scans]

        if axes is None:
            fig = plt.figure()
            axes = fig.add_subplot(111, projection='3d')
        plot_3d_lines(axes, data[signal], data[xaxis], data.get(values, None), labels=labels, **kwargs)
        ttl = self.exp.generate_scans_title(*scan_files)
        axes.set_title(ttl)

        x_lab, signal_label, value_label = hdf_map.generate_ids(xaxis, signal, values, modify_missing=False)
        axes.set_xlabel(x_lab)
        axes.set_ylabel(value_label)
        axes.set_zlabel(signal_label)
        self._set_axes(x_lab, value_label, signal_label, ttl)
        if legend:
            axes.legend()
        return axes

    def surface_3d(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
                   xaxis: str = 'axes', signal: str = 'signal', values: str | None = None,
                   axes: Axes3D | None = None, clim: tuple[float, float] | None = None,
                   axlim: str = 'image', **kwargs) -> Axes3D:
        """
        Create matplotlib figure with a 3D image

            axes = exp.plot.surface_3d(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

        :param scan_files: scan number or filename (multiple allowed)
        :param hdf_map: hdfmap object or None
        :param xaxis: str name or path of array to plot on x axis
        :param signal: str name or path of array to plot on z axis
        :param values: str name or path of float value to distinguish different scans
        :param axes: matplotlib.axes3D subplot, or None to create a figure
        :param clim: None or [min, max] values for color cutoff from plt.clim
        :param axlim: axis limits from plt.axis
        :param kwargs: given directly to plt.pcolormesh(..., **kwargs)
        :return: axes object
        """
        first_file = self.exp.get_scan_filename(scan_files[0])
        hdf_map = hdfmap.create_nexus_map(first_file) if hdf_map is None else hdf_map
        x, y, z = self.exp.generate_mesh(*scan_files, hdf_map=hdf_map,
                                         axes=xaxis, signal=signal, values=values)

        if axes is None:
            fig = plt.figure()
            axes = fig.add_subplot(111, projection='3d')
        plot_3d_surface(axes=axes, image=z, xdata=x, ydata=y, clim=clim, axlim=axlim, **kwargs)
        ttl = self.exp.generate_scans_title(*scan_files)
        axes.set_title(ttl)

        x_lab, signal_label, value_label = hdf_map.generate_ids(xaxis, signal, values, modify_missing=False)
        axes.set_xlabel(x_lab)
        axes.set_ylabel(value_label)
        axes.set_zlabel(signal_label)
        self._set_axes(x_lab, value_label, signal_label, ttl)
        return axes

    def metadata(self, *scan_files: ScanFile, values: str | list[str], hdf_map: hdfmap.NexusMap | None = None,
                 axes: plt.Axes | None = None, use_time: bool = False, x_axis: str | None = None) -> plt.Axes:
        """
        Create matplotlib figure with plot of metadata vs scan number

            exp.plot.metadata(*range(-10, 0), values='Tsample', use_time=True)

        :param scan_files: scan number or filename (multiple allowed)
        :param values: field name or path of float value to distinguish different scans
        :param hdf_map: hdfmap object or None
        :param axes: matplotlib.axes subplot, or None to create a figure
        :param use_time: if True, plots scan start_time vs values
        :param x_axis: str name or path of array to plot on x-axis (overridden by use_time)
        :return: axes object
        """
        scans = self.exp.scans(*scan_files, hdf_map=hdf_map)
        ttl = self.exp.generate_scans_title(*scan_files)

        values = [values] if isinstance(values, str) else values
        data = self.exp.join_scan_data(*scans, hdf_map=hdf_map, data_fields=values)

        if use_time:
            x_label = 'Time'
            x_data = [scan.start_end_duration()[0] for scan in scans]
        elif x_axis:
            x_label = x_axis
            x_data,  = self.exp.join_scan_arrays(*scans, hdf_map=hdf_map, data_fields=[x_axis])
        else:
            x_label = 'Scan number'
            x_data = [scan.scan_number() for scan in scans]
        if axes is None:
            fig, axes = plt.subplots()

        for name in data:
            axes.plot(x_data, data[name], '-o', label=name)
        axes.set_xlabel(x_label)
        axes.legend()
        axes.set_title(ttl)
        self._set_axes(x_label, 'metadata', title=ttl)
        return axes

    def axes_labels(self, axes: plt.Axes | None = None, x_label: bool | str | None = True,
                    y_label: bool | str | None = True, z_label: bool | str | None = True,
                    title: bool | str | None = True, legend: bool | None = True):
        """
        Set the axes labels using default or specified labels

        Each axis can be one of three values:

            - True: Use the last plotted axes or the default one
            - 'expression': convert expression into the axis name (defaults are replaced with actual names)
            - None: axis is not updated

        :param axes: matplotlib Axes object
        :param x_label: x-axis label
        :param y_label: y-axis label
        :param z_label: z-axis label (if available)
        :param title: axis title
        :param legend: True/False - add legend
        """
        if axes is None:
            axes = plt.gca()

        def update(fn, value, default):
            if value:  # True or str
                if not isinstance(value, str): # True
                    value = default
                fn(value)

        update(axes.set_title, title, self._title)

        if z_label and isinstance(axes, Axes3D):
            # assume 3D plot with set_zlabel
            update(axes.set_xlabel, x_label, self._x_axis or 'axes0')
            update(axes.set_ylabel, y_label, self._y_axis or 'axes1')
            update(axes.set_zlabel, z_label, self._z_axis or 'signal')
        else:
            update(axes.set_xlabel, x_label, self._x_axis or 'axes')
            update(axes.set_ylabel, y_label, self._y_axis or 'signal')

        if legend:
            handles, labels = axes.get_legend_handles_labels()
            if handles:
                axes.legend()

axes_labels(axes=None, x_label=True, y_label=True, z_label=True, title=True, legend=True)

Set the axes labels using default or specified labels

Each axis can be one of three values:

- True: Use the last plotted axes or the default one
- 'expression': convert expression into the axis name (defaults are replaced with actual names)
- None: axis is not updated

Parameters:

Name Type Description Default
axes Axes | None

matplotlib Axes object

None
x_label bool | str | None

x-axis label

True
y_label bool | str | None

y-axis label

True
z_label bool | str | None

z-axis label (if available)

True
title bool | str | None

axis title

True
legend bool | None

True/False - add legend

True
Source code in mmg_toolbox/plotting/exp_plot_manager.py
def axes_labels(self, axes: plt.Axes | None = None, x_label: bool | str | None = True,
                y_label: bool | str | None = True, z_label: bool | str | None = True,
                title: bool | str | None = True, legend: bool | None = True):
    """
    Set the axes labels using default or specified labels

    Each axis can be one of three values:

        - True: Use the last plotted axes or the default one
        - 'expression': convert expression into the axis name (defaults are replaced with actual names)
        - None: axis is not updated

    :param axes: matplotlib Axes object
    :param x_label: x-axis label
    :param y_label: y-axis label
    :param z_label: z-axis label (if available)
    :param title: axis title
    :param legend: True/False - add legend
    """
    if axes is None:
        axes = plt.gca()

    def update(fn, value, default):
        if value:  # True or str
            if not isinstance(value, str): # True
                value = default
            fn(value)

    update(axes.set_title, title, self._title)

    if z_label and isinstance(axes, Axes3D):
        # assume 3D plot with set_zlabel
        update(axes.set_xlabel, x_label, self._x_axis or 'axes0')
        update(axes.set_ylabel, y_label, self._y_axis or 'axes1')
        update(axes.set_zlabel, z_label, self._z_axis or 'signal')
    else:
        update(axes.set_xlabel, x_label, self._x_axis or 'axes')
        update(axes.set_ylabel, y_label, self._y_axis or 'signal')

    if legend:
        handles, labels = axes.get_legend_handles_labels()
        if handles:
            axes.legend()

detail(scan_file=-1, hdf_map=None, xaxis='axes', yaxis='signal', index=None, clim=None, cmap=DEFAULT_CMAP, **kwargs)

Create matplotlib figure with plot of the scan and detector image

Parameters:

Name Type Description Default
scan_file ScanFile

scan number or filename

-1
hdf_map NexusMap | None

hdfmap object or None

None
xaxis str

str name or address of array to plot on x axis

'axes'
yaxis str | list[str]

str name or address of array to plot on y axis, also accepts list of names for multiple plots

'signal'
index int | tuple | slice | None

int, detector image index, 0-length of scan, if None, use centre index

None
clim tuple[float, float] | None

[min, max] colormap cut-offs (None for auto)

None
cmap str

str colormap name (None for auto)

DEFAULT_CMAP
kwargs

given directly to plt.plot(..., args, *kwars)

{}

Returns:

Type Description
Figure

figure object

Source code in mmg_toolbox/plotting/exp_plot_manager.py
def detail(self, scan_file: ScanFile = -1, hdf_map: hdfmap.NexusMap | None = None,
           xaxis: str = 'axes', yaxis: str | list[str] = 'signal',
           index: int | tuple | slice | None = None, clim: tuple[float, float] | None = None,
           cmap: str = DEFAULT_CMAP, **kwargs) -> plt.Figure:
    """
    Create matplotlib figure with plot of the scan and detector image
    :param scan_file: scan number or filename
    :param hdf_map: hdfmap object or None
    :param xaxis: str name or address of array to plot on x axis
    :param yaxis: str name or address of array to plot on y axis, also accepts list of names for multiple plots
    :param index: int, detector image index, 0-length of scan, if None, use centre index
    :param clim: [min, max] colormap cut-offs (None for auto)
    :param cmap: str colormap name (None for auto)
    :param kwargs: given directly to plt.plot(..., *args, **kwars)
    :return: figure object
    """
    scan = self.exp.scans(scan_file, hdf_map=hdf_map)[0]

    # Create figure
    fig, ((lt, rt), (lb, rb)) = plt.subplots(2, 2, figsize=[FIG_SIZE[0] * 1.2, FIG_SIZE[1] * 1.2], dpi=FIG_DPI)
    fig.subplots_adjust(hspace=0.35, left=0.1, right=0.95)
    fig.suptitle(scan.title())

    # Top left - line plot
    scan.plot(xaxis, yaxis, axes=lt, **kwargs)
    self._set_axes_from_scans(scan)
    lt.set_title(None)

    # Top right - image plot
    if scan.map.image_data:
        scan.plot.image(index, xaxis, cmap=cmap, clim=clim, axes=rt)
        rt.set_title(None)

    # Bottom-Left - details
    details = self.exp.scan_str(scan_file, hdf_map=hdf_map)
    lb.text(-0.2, 1, details, ha='left', va='top', multialignment="left", fontsize=12, wrap=True)
    lb.set_axis_off()

    # Bottom-Right - fit results
    rb.set_axis_off()
    if 'fit' in yaxis:
        fit_report = str(scan.fit)
        rb.text(-0.2, 1, fit_report, ha='left', va='top', multialignment="left", fontsize=12, wrap=True)
    return fig

image(scan_file=-1, hdf_map=None, index=None, xaxis='axes', axes=None, clim=None, cmap=DEFAULT_CMAP, colorbar=False, **kwargs)

Plot image in matplotlib figure (if available)

Parameters:

Name Type Description Default
scan_file ScanFile

scan number or filename

-1
hdf_map NexusMap | None

hdfmap object or None

None
index int | tuple | slice | None

int, detector image index, 0-length of scan, if None, use centre index

None
xaxis str

name or address of xaxis dataset

'axes'
axes Axes | None

matplotlib axes to plot on (None to create figure)

None
clim tuple[float, float] | None

[min, max] colormap cut-offs (None for auto)

None
cmap str

str colormap name (None for auto)

DEFAULT_CMAP
colorbar bool

False/ True add colorbar to plot

False
kwargs

additional arguments for plot_detector_image

{}

Returns:

Type Description
Axes | None

axes object or None if no image

Source code in mmg_toolbox/plotting/exp_plot_manager.py
def image(self,  scan_file: ScanFile = -1, hdf_map: hdfmap.NexusMap | None = None,
          index: int | tuple | slice | None = None, xaxis: str = 'axes',
          axes: plt.Axes | None = None, clim: tuple[float, float] | None = None,
          cmap: str = DEFAULT_CMAP, colorbar: bool = False, **kwargs) -> plt.Axes | None:
    """
    Plot image in matplotlib figure (if available)
    :param scan_file: scan number or filename
    :param hdf_map: hdfmap object or None
    :param index: int, detector image index, 0-length of scan, if None, use centre index
    :param xaxis: name or address of xaxis dataset
    :param axes: matplotlib axes to plot on (None to create figure)
    :param clim: [min, max] colormap cut-offs (None for auto)
    :param cmap: str colormap name (None for auto)
    :param colorbar: False/ True add colorbar to plot
    :param kwargs: additional arguments for plot_detector_image
    :return: axes object or None if no image
    """
    scan = self.exp.scans(scan_file, hdf_map=hdf_map)[0]
    if scan.map.image_data:
        ax = scan.plot.image(index, xaxis, axes, clim, cmap, colorbar, **kwargs)
        self._set_axes_from_scans(scan)
        return ax
    return None

lines_3d(*scan_files, hdf_map=None, xaxis='axes', signal='signal', values=None, axes=None, legend=False, **kwargs)

Create matplotlib figure with a 2D image

axes = exp.plot.surface_2d(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

Parameters:

Name Type Description Default
scan_files ScanFile

scan number or filename (multiple allowed)

()
hdf_map NexusMap | None

hdfmap object or None

None
xaxis str

str name or path of array to plot on x axis

'axes'
signal str

str name or path of array to plot on z axis

'signal'
values str | None

str name or path of float value to distinguish different scans

None
axes Axes3D | None

matplotlib.axes subplot, or None to create a figure

None
legend bool

if True, adds a legend

False
kwargs

given directly to plt.plot(..., **kwargs)

{}

Returns:

Type Description
Axes3D

axes object

Source code in mmg_toolbox/plotting/exp_plot_manager.py
def lines_3d(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
             xaxis: str = 'axes', signal: str = 'signal', values: str | None = None,
             axes: Axes3D | None = None, legend: bool = False, **kwargs) -> Axes3D:
    """
    Create matplotlib figure with a 2D image

        axes = exp.plot.surface_2d(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

    :param scan_files: scan number or filename (multiple allowed)
    :param hdf_map: hdfmap object or None
    :param xaxis: str name or path of array to plot on x axis
    :param signal: str name or path of array to plot on z axis
    :param values: str name or path of float value to distinguish different scans
    :param axes: matplotlib.axes subplot, or None to create a figure
    :param legend: if True, adds a legend
    :param kwargs: given directly to plt.plot(..., **kwargs)
    :return: axes object
    """
    first_file = self.exp.get_scan_filename(scan_files[0])
    hdf_map = hdfmap.create_nexus_map(first_file) if hdf_map is None else hdf_map
    scans = self.exp.scans(*scan_files, hdf_map=hdf_map)
    data_fields = [signal, xaxis] + ([values] if values is not None else [])
    data = self.exp.join_scan_data(*scan_files, hdf_map=hdf_map, data_fields=data_fields)
    labels = [scan.label() for scan in scans]

    if axes is None:
        fig = plt.figure()
        axes = fig.add_subplot(111, projection='3d')
    plot_3d_lines(axes, data[signal], data[xaxis], data.get(values, None), labels=labels, **kwargs)
    ttl = self.exp.generate_scans_title(*scan_files)
    axes.set_title(ttl)

    x_lab, signal_label, value_label = hdf_map.generate_ids(xaxis, signal, values, modify_missing=False)
    axes.set_xlabel(x_lab)
    axes.set_ylabel(value_label)
    axes.set_zlabel(signal_label)
    self._set_axes(x_lab, value_label, signal_label, ttl)
    if legend:
        axes.legend()
    return axes

metadata(*scan_files, values, hdf_map=None, axes=None, use_time=False, x_axis=None)

Create matplotlib figure with plot of metadata vs scan number

exp.plot.metadata(*range(-10, 0), values='Tsample', use_time=True)

Parameters:

Name Type Description Default
scan_files ScanFile

scan number or filename (multiple allowed)

()
values str | list[str]

field name or path of float value to distinguish different scans

required
hdf_map NexusMap | None

hdfmap object or None

None
axes Axes | None

matplotlib.axes subplot, or None to create a figure

None
use_time bool

if True, plots scan start_time vs values

False
x_axis str | None

str name or path of array to plot on x-axis (overridden by use_time)

None

Returns:

Type Description
Axes

axes object

Source code in mmg_toolbox/plotting/exp_plot_manager.py
def metadata(self, *scan_files: ScanFile, values: str | list[str], hdf_map: hdfmap.NexusMap | None = None,
             axes: plt.Axes | None = None, use_time: bool = False, x_axis: str | None = None) -> plt.Axes:
    """
    Create matplotlib figure with plot of metadata vs scan number

        exp.plot.metadata(*range(-10, 0), values='Tsample', use_time=True)

    :param scan_files: scan number or filename (multiple allowed)
    :param values: field name or path of float value to distinguish different scans
    :param hdf_map: hdfmap object or None
    :param axes: matplotlib.axes subplot, or None to create a figure
    :param use_time: if True, plots scan start_time vs values
    :param x_axis: str name or path of array to plot on x-axis (overridden by use_time)
    :return: axes object
    """
    scans = self.exp.scans(*scan_files, hdf_map=hdf_map)
    ttl = self.exp.generate_scans_title(*scan_files)

    values = [values] if isinstance(values, str) else values
    data = self.exp.join_scan_data(*scans, hdf_map=hdf_map, data_fields=values)

    if use_time:
        x_label = 'Time'
        x_data = [scan.start_end_duration()[0] for scan in scans]
    elif x_axis:
        x_label = x_axis
        x_data,  = self.exp.join_scan_arrays(*scans, hdf_map=hdf_map, data_fields=[x_axis])
    else:
        x_label = 'Scan number'
        x_data = [scan.scan_number() for scan in scans]
    if axes is None:
        fig, axes = plt.subplots()

    for name in data:
        axes.plot(x_data, data[name], '-o', label=name)
    axes.set_xlabel(x_label)
    axes.legend()
    axes.set_title(ttl)
    self._set_axes(x_label, 'metadata', title=ttl)
    return axes

multi_image(*scan_files, hdf_map=None, index=None, xaxis='axes', clim=None, cmap=DEFAULT_CMAP, colorbar=False, **kwargs)

Plot scan images in matplotlib figure (if available)

Parameters:

Name Type Description Default
scan_files ScanFile

scan number or filename (multiple allowed)

()
hdf_map NexusMap | None

hdfmap object or None

None
index int | tuple | slice | None

int, detector image index, 0-length of scan, if None, use centre index

None
xaxis str

name or address of xaxis dataset

'axes'
clim tuple[float, float] | None

[min, max] colormap cut-offs (None for auto)

None
cmap str

str colormap name (None for auto)

DEFAULT_CMAP
colorbar bool

False/ True add colorbar to plot

False
kwargs

additional arguments for plot_detector_image

{}

Returns:

Type Description
list[tuple[Figure, Axes]]

[(Figure, Axes)] for each scan

Source code in mmg_toolbox/plotting/exp_plot_manager.py
def multi_image(self,  *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
                index: int | tuple | slice | None = None, xaxis: str = 'axes',
                clim: tuple[float, float] | None = None, cmap: str = DEFAULT_CMAP,
                colorbar: bool = False, **kwargs) -> list[tuple[plt.Figure, plt.Axes]]:
    """
    Plot scan images in matplotlib figure (if available)
    :param scan_files: scan number or filename (multiple allowed)
    :param hdf_map: hdfmap object or None
    :param index: int, detector image index, 0-length of scan, if None, use centre index
    :param xaxis: name or address of xaxis dataset
    :param clim: [min, max] colormap cut-offs (None for auto)
    :param cmap: str colormap name (None for auto)
    :param colorbar: False/ True add colorbar to plot
    :param kwargs: additional arguments for plot_detector_image
    :return: [(Figure, Axes)] for each scan
    """
    fig_axes = generate_subplots(len(scan_files))
    for scan, (fig, axes) in zip(scan_files, fig_axes):
        self.image(scan, axes=axes, hdf_map=hdf_map, index=index, xaxis=xaxis,
                   clim=clim, cmap=cmap, colorbar=colorbar, **kwargs)
    return fig_axes

multi_lines(*scan_files, hdf_map=None, xaxis='axes', yaxis='signal', value=None, axes=None, **kwargs)

Create matplotlib figure with a line plot from a or several scans

axes = exp.plot.multi_lines(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

Parameters:

Name Type Description Default
scan_files ScanFile

scan number or filename (multiple allowed)

()
hdf_map NexusMap | None

hdfmap object or None

None
xaxis str

str name or path of array to plot on x axis

'axes'
yaxis str

str name or path of array to plot on y axis

'signal'
value str | None

str name or path of float value to distinguish lines

None
axes Axes | None

matplotlib.axes subplot, or None to create a figure

None
kwargs

given directly to plt.plot(..., **kwars)

{}

Returns:

Type Description
Axes

axes object

Source code in mmg_toolbox/plotting/exp_plot_manager.py
def multi_lines(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
                xaxis: str = 'axes', yaxis: str = 'signal', value: str | None = None,
                axes: plt.Axes | None = None, **kwargs) -> plt.Axes:
    """
    Create matplotlib figure with a line plot from a or several scans

        axes = exp.plot.multi_lines(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

    :param scan_files: scan number or filename (multiple allowed)
    :param hdf_map: hdfmap object or None
    :param xaxis: str name or path of array to plot on x axis
    :param yaxis: str name or path of array to plot on y axis
    :param value: str name or path of float value to distinguish lines
    :param axes: matplotlib.axes subplot, or None to create a figure
    :param kwargs: given directly to plt.plot(..., **kwars)
    :return: axes object
    """
    scans = self.exp.scans(*scan_files, hdf_map=hdf_map)
    hdf_map = scans[0].map

    plot_data = []
    for scan in scans:
        with hdfmap.load_hdf(scan.filename) as hdf:
            xdata = hdf_map.eval(hdf, xaxis)
            ydata = hdf_map.eval(hdf, yaxis)
            value_data = np.mean(hdf_map.eval(hdf, value)) if value else None
            plot_data.append((value_data, xdata, ydata))

    if axes is None:
        fig, axes = plt.subplots()
    lines, sm = plot_lines(axes, *plot_data, **kwargs)

    x_lab, y_lab, value_label = hdf_map.generate_ids(xaxis, yaxis, value, modify_missing=False)
    axes.set_xlabel(x_lab)
    axes.set_ylabel(y_lab)
    axes.set_title(self.exp.generate_scans_title(*scan_files, hdf_map=hdf_map))
    self._set_axes_from_scans(*scans)

    plt.colorbar(sm, ax=axes, label=value_label)
    return axes

multi_plot(*scan_files, hdf_map=None, xaxis='axes', yaxis='signal', value=None, subplots=(4, 4), **kwargs)

Create matplotlib figure with a line plot from a or several scans

axes = exp.plot.multi_plot(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

Parameters:

Name Type Description Default
scan_files ScanFile

scan number or filename (multiple allowed)

()
hdf_map NexusMap | None

hdfmap object or None

None
xaxis str

str name or path of array to plot on x axis

'axes'
yaxis str | list[str]

str name or path of array to plot on y axis, or a list of names for multiple plots per axis

'signal'
value str | None

str name or path of float value to distinguish lines

None
subplots tuple[int, int]

[int, int] number of subplots per figure [vertical, horizontal]

(4, 4)
kwargs

given directly to plt.plot(..., **kwars)

{}

Returns:

Type Description
list[tuple[Figure, Axes]]

list of figures

Source code in mmg_toolbox/plotting/exp_plot_manager.py
def multi_plot(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
               xaxis: str = 'axes', yaxis: str | list[str] = 'signal', value: str | None = None,
               subplots: tuple[int, int] = (4, 4), **kwargs) ->  list[tuple[plt.Figure, plt.Axes]]:
    """
    Create matplotlib figure with a line plot from a or several scans

        axes = exp.plot.multi_plot(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

    :param scan_files: scan number or filename (multiple allowed)
    :param hdf_map: hdfmap object or None
    :param xaxis: str name or path of array to plot on x axis
    :param yaxis: str name or path of array to plot on y axis, or a list of names for multiple plots per axis
    :param value: str name or path of float value to distinguish lines
    :param subplots: [int, int] number of subplots per figure [vertical, horizontal]
    :param kwargs: given directly to plt.plot(..., **kwars)
    :return: list of figures
    """
    scans = self.exp.scans(*scan_files, hdf_map=hdf_map)
    ttl = self.exp.generate_scans_title(*scan_files)
    fig_ax = generate_subplots(len(scan_files), subplots=subplots, suptitle=ttl)

    for scan, (fig, ax) in zip(scans, fig_ax):
        scan.plot.plot(xaxis=xaxis, yaxis=yaxis, axes=ax, **kwargs)
        val = scan.format("\n%s = {%s}" % (value, value)) if value is not None else ""
        ttl_exp = scan.title() + val
        ax.set_title(ttl_exp)
    self._set_axes_from_scans(*scans)
    return fig_ax

plot(*scan_files, hdf_map=None, xaxis='axes', yaxis='signal', axes=None, **kwargs)

Create matplotlib figure with a line plot from a or several scans

axes = exp.plot.plot(file1, file2, xaxis='eta', yaxis='roi2_sum')

Parameters:

Name Type Description Default
scan_files ScanFile

scan number or filename (multiple allowed)

()
hdf_map NexusMap | None

hdfmap object or None

None
xaxis str

str name or address of array to plot on x axis

'axes'
yaxis str | list[str]

str name or address of array to plot on y axis, also accepts list of names for multiple lines

'signal'
axes Axes | None

matplotlib.axes subplot, or None to create a figure

None
kwargs

given directly to plt.plot(..., **kwars)

{}

Returns:

Type Description
Axes

axes object

Source code in mmg_toolbox/plotting/exp_plot_manager.py
def plot(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
         xaxis: str = 'axes', yaxis: str | list[str] = 'signal', axes: plt.Axes | None = None, **kwargs) -> plt.Axes:
    """
    Create matplotlib figure with a line plot from a or several scans

        axes = exp.plot.plot(file1, file2, xaxis='eta', yaxis='roi2_sum')

    :param scan_files: scan number or filename (multiple allowed)
    :param hdf_map: hdfmap object or None
    :param xaxis: str name or address of array to plot on x axis
    :param yaxis: str name or address of array to plot on y axis, also accepts list of names for multiple lines
    :param axes: matplotlib.axes subplot, or None to create a figure
    :param kwargs: given directly to plt.plot(..., **kwars)
    :return: axes object
    """
    scans = self.exp.scans(*scan_files, hdf_map=hdf_map)
    if axes is None:
        fig, axes = plt.subplots()
    for scan in scans:
        scan.plot.plot(xaxis, yaxis, axes=axes, **kwargs)
    if len(scan_files) > 1:
        axes.legend(scan_files)
    self._set_axes_from_scans(*scans)
    if self._title:
        axes.set_title(self._title)
    return axes

surface_2d(*scan_files, hdf_map=None, xaxis='axes', signal='signal', values=None, axes=None, clim=None, axlim='image', **kwargs)

Create matplotlib figure with a 2D image

axes = exp.plot.surface_2d(*range(-10, 0), xaxis='eta', signal='roi2_sum', values='Tsample')

Parameters:

Name Type Description Default
scan_files ScanFile

scan number or filename (multiple allowed)

()
hdf_map NexusMap | None

hdfmap object or None

None
xaxis str

str name or path of array to plot on x axis

'axes'
signal str

str name or path of array to plot on z axis

'signal'
values str | None

str name or path of float value to distinguish different scans

None
axes Axes | None

matplotlib.axes subplot, or None to create a figure

None
clim tuple[float, float] | None

None or [min, max] values for color cutoff from plt.clim

None
axlim str

axis limits from plt.axis

'image'
kwargs

given directly to plt.pcolormesh(..., **kwargs)

{}

Returns:

Type Description
Axes

axes object

Source code in mmg_toolbox/plotting/exp_plot_manager.py
def surface_2d(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
               xaxis: str = 'axes', signal: str = 'signal', values: str | None = None,
               axes: plt.Axes | None = None, clim: tuple[float, float] | None = None,
               axlim: str = 'image', **kwargs) -> plt.Axes:
    """
    Create matplotlib figure with a 2D image

        axes = exp.plot.surface_2d(*range(-10, 0), xaxis='eta', signal='roi2_sum', values='Tsample')

    :param scan_files: scan number or filename (multiple allowed)
    :param hdf_map: hdfmap object or None
    :param xaxis: str name or path of array to plot on x axis
    :param signal: str name or path of array to plot on z axis
    :param values: str name or path of float value to distinguish different scans
    :param axes: matplotlib.axes subplot, or None to create a figure
    :param clim: None or [min, max] values for color cutoff from plt.clim
    :param axlim: axis limits from plt.axis
    :param kwargs: given directly to plt.pcolormesh(..., **kwargs)
    :return: axes object
    """
    first_file = self.exp.get_scan_filename(scan_files[0])
    hdf_map = hdfmap.create_nexus_map(first_file) if hdf_map is None else hdf_map
    x, y, z = self.exp.generate_mesh(*scan_files, hdf_map=hdf_map,
                                     axes=xaxis, signal=signal, values=values)

    if axes is None:
        fig, axes = plt.subplots()
    surf = plot_2d_surface(axes=axes, image=z, xdata=x, ydata=y, clim=clim, axlim=axlim, **kwargs)
    ttl = self.exp.generate_scans_title(*scan_files)
    axes.set_title(ttl)

    x_lab, y_lab, value_label = hdf_map.generate_ids(xaxis, signal, values, modify_missing=False)
    axes.set_xlabel(x_lab)
    axes.set_ylabel(value_label)
    axes.figure.colorbar(surf, ax=axes, label=signal)
    self._set_axes(x_lab, y_lab, signal, ttl)
    return axes

surface_3d(*scan_files, hdf_map=None, xaxis='axes', signal='signal', values=None, axes=None, clim=None, axlim='image', **kwargs)

Create matplotlib figure with a 3D image

axes = exp.plot.surface_3d(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

Parameters:

Name Type Description Default
scan_files ScanFile

scan number or filename (multiple allowed)

()
hdf_map NexusMap | None

hdfmap object or None

None
xaxis str

str name or path of array to plot on x axis

'axes'
signal str

str name or path of array to plot on z axis

'signal'
values str | None

str name or path of float value to distinguish different scans

None
axes Axes3D | None

matplotlib.axes3D subplot, or None to create a figure

None
clim tuple[float, float] | None

None or [min, max] values for color cutoff from plt.clim

None
axlim str

axis limits from plt.axis

'image'
kwargs

given directly to plt.pcolormesh(..., **kwargs)

{}

Returns:

Type Description
Axes3D

axes object

Source code in mmg_toolbox/plotting/exp_plot_manager.py
def surface_3d(self, *scan_files: ScanFile, hdf_map: hdfmap.NexusMap | None = None,
               xaxis: str = 'axes', signal: str = 'signal', values: str | None = None,
               axes: Axes3D | None = None, clim: tuple[float, float] | None = None,
               axlim: str = 'image', **kwargs) -> Axes3D:
    """
    Create matplotlib figure with a 3D image

        axes = exp.plot.surface_3d(*range(-10, 0), xaxis='eta', yaxis='roi2_sum', value='Tsample')

    :param scan_files: scan number or filename (multiple allowed)
    :param hdf_map: hdfmap object or None
    :param xaxis: str name or path of array to plot on x axis
    :param signal: str name or path of array to plot on z axis
    :param values: str name or path of float value to distinguish different scans
    :param axes: matplotlib.axes3D subplot, or None to create a figure
    :param clim: None or [min, max] values for color cutoff from plt.clim
    :param axlim: axis limits from plt.axis
    :param kwargs: given directly to plt.pcolormesh(..., **kwargs)
    :return: axes object
    """
    first_file = self.exp.get_scan_filename(scan_files[0])
    hdf_map = hdfmap.create_nexus_map(first_file) if hdf_map is None else hdf_map
    x, y, z = self.exp.generate_mesh(*scan_files, hdf_map=hdf_map,
                                     axes=xaxis, signal=signal, values=values)

    if axes is None:
        fig = plt.figure()
        axes = fig.add_subplot(111, projection='3d')
    plot_3d_surface(axes=axes, image=z, xdata=x, ydata=y, clim=clim, axlim=axlim, **kwargs)
    ttl = self.exp.generate_scans_title(*scan_files)
    axes.set_title(ttl)

    x_lab, signal_label, value_label = hdf_map.generate_ids(xaxis, signal, values, modify_missing=False)
    axes.set_xlabel(x_lab)
    axes.set_ylabel(value_label)
    axes.set_zlabel(signal_label)
    self._set_axes(x_lab, value_label, signal_label, ttl)
    return axes