plot module

Plotting functions.

plot.plot_abs(data, sel=None, every=None, hide_lines=False, cmap=None, lbls=None, error_bars=False, title='short', tpause=None, folder_parent=None, xlabel='q ($\\AA^{-1}$)', ylabel=None, xlim=(0, None), ylim=(0, None), fig=None, ax=None, return_fig=False, return_ax=False, legend_ncols='auto', legend_nlines=None, figsize=None, map2D=False, map_clim=None, return_lines=False)[source]

Plot absolute patterns.

TO DO: should plot averages absolute patterns

diff_av(q, t) + <abs(q, tref)>

TO DO: map2D should go to plot_raw_abs and plot_raw_diffs

Patterns can be hidden or shown upon a click on the corresponding legend entry.

Parameters:
  • data (dict or tuple) – Data reduction result obtained from the txs.datared.datared().

  • sel (list or slice or None, optional) – List of time-delays (strings) for the plot. Only patterns corresponding to the time-delays list will be displayed in the plot. If None (default), all patterns will be displayed.

  • every (int or None, optional) – Spacing at which time-delays for the plot will be selected. If ‘sel’ is not None, ‘every’ will be applied to ‘sel’ rather than to the whole list of time-delays. If None (default), all patterns will be displayed.

  • hide_lines (bool, optional) – If True, all selected curves are hidden. Default is False.

  • cmap (str or None, optional) – Name of matplotlib colormap.

  • lbls (list or None, optional) – List of labels to be used for the plot legend. Default is None.

  • error_bars (bool, optional) – If True, patterns are plotted with error bars. Default is False.

  • title (str or None, optional) – Figure title. If None, the full data folder is used as title. If ‘short’ (default), the data folder is used as title, but only the last 2 subfolders are kept and the other parent subfolders are removed.

  • tpause (float or None, optional) – Interval time after which the figure is updated.

  • legend_ncols (int or 'auto' or None) – If ‘auto’ (default), the number of columns in the legend is modified automatically and optimized on the basis of the total number of curves. (if nlines is Nones, the legend will use default matplotlib settings) If int, the legend will have ‘ncols’ columns. If None, the legend will use default matplotlib settings. (same as ncols=1).

  • legend_nlines (int or None) – If ‘auto’ (default), the number of lines in the legend is modified automatically and optimized to fit figure height. If None (default), the legend will use default matplotlib settings (no limitations on the number of lines is applied). If int, the legend will have ‘nlines’ lines.

  • map2D (bool, optionnal) – If True, will display the patterns as a 2D map (image_number,q)

  • map_clim (tupple or None) – Ignored if map2D is False

plot.plot_azim_regroup(img, ai, N=600, M=360, center=None, vline=None, label=None, ax=None, return_ax=False, cmap='inferno', clim=None)[source]

Perform and plot azimuthal 2d regrouping (“caking”) of an image

Azimuthal regrouping is performed over N radian bins and M angular steps.

Parameters:
  • img (array_like) – Image.

  • ai (pyFAI ...) – pyFAI azimuthal integrator obj.

  • N (int, optional) – Number of radial bins. Default is 600.

  • M (int, optional) – Number of angular steps. Default is 360.

  • cmap (str, optional) – Figure colormap. Default is ‘inferno’.

  • clim (tuple or None, optional) – Figure color limits. Default is None.

plot.plot_diffs(data, sel=None, every=None, hide_lines=False, cmap=None, yscale='diff', lbls=None, error_bars=False, title='short', plot_ref=True, plot_abs_mean=False, diff_plus_ref=False, tpause=None, tdigits=2, legend_ncols='auto', legend_nlines=None, xlabel='q ($\\AA^{-1}$)', xlim=(0, None), ylim=None, figsize=None, fig=None, ax=None, return_fig=False, return_ax=False, return_lines=False)[source]

Plot time-resolved difference patterns (averaged over different delays).

Difference patterns can be hidden or shown upon a click on the corresponding legend entry.

Parameters:
  • data (dict or tuple) – Data reduction result obtained from the txs.datared.datared().

  • sel (list or slice or None, optional) – List of time-delays (strings) for the plot. Only difference patterns corresponding to the time-delays list will be displayed in the plot. If None (default), all difference patterns will be displayed.

  • every (int or None, optional) – Spacing at which time-delays for the plot will be selected. If ‘sel’ is not None, ‘every’ will be applied to ‘sel’ rather than to the whole list of time-delays. If None (default), all difference patterns will be displayed.

  • hide_lines (bool, optional) – If True, all selected curves are hidden. Default is False.

  • cmap (str or None, optional) – Name of matplotlib colormap.

  • yscale (str, optional) – If ‘diff’ (default), scattering intensity differences are plotted. If ‘qdiff’, scattering intensity difference times q-values are plotted.

  • lbls (list or None, optional) – List of labels to be used for the plot legend. Default is None.

  • error_bars (bool, optional) – If True, patterns are plotted with error bars. Default is False.

  • title (str or None, optional) – Figure title. If None, the full data folder is used as title. If ‘short’ (default), the data folder is used as title, but only the last 2 subfolders are kept and the other parent subfolders are removed.

  • remove_folder_parent

  • plot_ref (bool, optional) – If True (default), the difference pattern corresponding to the reference time-delay is plotted.

  • plot_abs_mean (bool, optional) – If True, the average absolute pattern (average over all data, irrespective of the time-delay) is plotted on a separate (top) panel. Default is False.

  • diff_plus_ref (bool, optional) – If True, will plot the absolute patterns for each time delay calculated as average of ref patterns + differential patterns

  • tpause (float or None, optional) – Interval time after which the figure is updated.

  • tdigits (int, optional) – Number of digits used for time-delay labels. Default is 2.

  • legend_ncols (int or 'auto' or None) – If ‘auto’ (default), the number of columns in the legend is modified automatically and optimized on the basis of the total number of curves. (if nlines is Nones, the legend will use default matplotlib settings) If int, the legend will have ‘ncols’ columns. If None, the legend will use default matplotlib settings. (same as ncols=1).

  • legend_nlines (int or None) – If ‘auto’ (default), the number of lines in the legend is modified automatically and optimized to fit figure height. If None (default), the legend will use default matplotlib settings (no limitations on the number of lines is applied). If int, the legend will have ‘nlines’ lines.

plot.plot_filt_hist(res, filt='red_chi2', bins=None, fig=None, ax=None)[source]

Plot histogram of filtering parameter (‘red_chi2’ or ‘pts_perc’).

plot.plot_motor_scan(res, qrange, td, abs_value=True, min_max=False, xscale=1, yscale=1, xlabel='scan motor position', title='auto', fig=None, ax=None)[source]

Plot average difference signal (averaged over a given q-range) as a function of a scanned motor position.

The motor position corresponding to the max value of the averaged difference signal is automatically calculated.

Parameters:
  • res (dict) – Result of txs.datared.datared() with ‘scan_motor’ != None.

  • qrange (array-like) – Range of q-values (min, max) to use for signal averaging.

  • td (str, optional) – Time-delay label corresponding to the data to use for the plot.

  • abs_value (bool, optional) – If True, the absolute value of difference patterns is used to calculate the best motor position. Default is True.

  • min_max (bool, optional) – If True, the difference between the max difference signal and the min difference signal is used to calculate the position (NO AVERAGED IS DONE!!!). Default is False.

  • xscale (float, optional) – Scaling factor for motor position values. Default is 1.

  • yscale (float, optional) – Scaling factor for signal. Default is 1.

  • xlabel (str, optional) – Label for signal plot x-axis. Default is “scan motor position”.BaseException

  • title (str or None, optional) – If None, the full data folder is used. If ‘auto’, the dataset name is used.

plot.track_abs_init(data, qmon=None, qnorm=None, title='short')[source]

Prepare new figure to monitor absolute scattering patterns and specific qrange(s).

Parameters:
  • data (output of txs.azav.integrate1d_dataset()) – Input data

  • qmon (tuple or list or None, optional) – Monitor q-range(s). If tuple, monitoring q-range is (qmon[0], qmon[1]). If list, each element of the list is a monitoring q-range. If None (default), only absolute patterns are tracked.

Return type:

plot.track_abs_update(data, fig, ax, ln, sig=None, qmon=None, qnorm=None)[source]

Update figure for absolute patterns tracking.

plot.track_diff_init(data, qmon=None, qnorm=None, track_t=None, title='short')[source]

Prepare new figure to monitor difference scattering patterns and specific qrange(s).

Parameters:
  • data (output of txs.azav.integrate1d_dataset()) – Input data

  • qmon (tuple or list or None, optional) – Monitor q-range(s). If tuple, monitoring q-range is (qmon[0], qmon[1]). If list, each element of the list is a monitoring q-range. If None (default), only absolute patterns are tracked.

Return type:

plot.track_diff_update(data, fig, ax, ln, sig=None, qmon=None, qnorm=None, track_t=None)[source]

Update figure for difference patterns tracking.