drtsans.plots package

Submodules

This module contains methods for plotting data objects

drtsans.plots.api module

drtsans.plots.api.plot_I1DAnnular(workspaces, filename, logy=True, backend: str = 'd3', errorbar_kwargs=None, **kwargs)[source]

Save a plot representative of the supplied I(phi) workspaces

Parameters:
  • workspaces (list, tuple, I1DAnnular) – A collection of I1DAnnular workspaces to plot.

  • filename (str) – The name of the file to save to. For the MATPLOTLIB backend, the type of file is determined from the file extension

  • logy (bool) – If true will set the intensity axis to logarithmic, otherwise leave it as linear

  • backend – Which backend to save the file using

  • errorbar_kwargs (dict) – Optional arguments to matplotlib.axes.Axes.errorbar Can be a comma separated list for each workspace e.g. {'label':'main,wing,both', 'color':'r,b,g', 'marker':'o,v,.'}

  • kwargs (dict) – Additional key word arguments for matplotlib.axes.Axes

drtsans.plots.api.plot_IQazimuthal(workspace, filename, backend: str = 'd3', qmin: float = None, qmax: float = None, wedges: List[Any] = None, symmetric_wedges: bool = True, mask_alpha=0.6, imshow_kwargs: Dict = {}, **kwargs)[source]

Save a plot of I(Qx, Qy). If qmin is specified, all I(Q) with Q less than qmin will be masked in output plot. If qmax is specified, all I(Q) with Q greater than qmax will be masked in output plot. If wedges are specified, all I(Q) out side of wedges will be masked in output plot.

Parameters:
  • workspace (IQazimuthal) – The workspace (i.e., I(Qx, Qy)) to plot. This assumes the data is binned on a constant grid.

  • filename (str) – The name of the file to save to. For the MATPLOTLIB backend, the type of file is determined from the file extension

  • qmin (float) – minimum 1D Q for plotting selection area

  • qmax (float) – maximum 1D Q for plotting selection area

  • wedges (~list or None) – list of tuples (angle_min, angle_max) for the wedges. Select wedges to plot. Both numbers have to be in the [-90,270) range. It will add the wedge offset by 180 degrees dependent on symmetric_wedges

  • symmetric_wedges (bool) – Add the wedge offset by 180 degrees if True

  • mask_alpha (float) – Opacity for for selection area

  • backend – Which backend to save the file using

  • imshow_kwargs (~dict) – Optional arguments to matplotlib.axes.Axes.imshow e.g. {"norm": LogNorm()}

  • kwargs (~dict) – Additional key word arguments for matplotlib.axes.Axes

drtsans.plots.api.plot_IQmod(workspaces, filename, loglog=True, backend: str = 'd3', errorbar_kwargs=None, **kwargs)[source]

Save a plot representative of the supplied workspaces

Parameters:
  • workspaces (list, tuple, IQmod) – A collection of IQmod workspaces to plot.

  • filename (str) – The name of the file to save to. For the MATPLOTLIB backend, the type of file is determined from the file extension

  • loglog (bool) – If true will set both axis to logarithmic, otherwise leave them as linear

  • backend – Which backend to save the file using

  • errorbar_kwargs (dict) – Optional arguments to matplotlib.axes.Axes.errorbar Can be a comma separated list for each workspace e.g. {'label':'main,wing,both', 'color':'r,b,g', 'marker':'o,v,.'}

  • kwargs (dict) – Additional key word arguments for matplotlib.axes.Axes

drtsans.plots.api.plot_detector(input_workspace, filename=None, backend: str = 'd3', axes_mode='tube-pixel', panel_name=None, figure_kwargs={'figsize': (8, 6)}, imshow_kwargs={'norm': <matplotlib.colors.LogNorm object>})[source]

Save a 2D plot representative of the supplied workspace

Parameters:
  • input_workspace (str, MatrixWorkspace) – The workspace to plot

  • filename (str) – The name of the file to save to. For the MATPLOTLIB backend, the type of file is determined from the file extension

  • backend – Which backend to save the file using

  • axes_mode (str) – Plot intensities versus different axes. Options are: ‘xy’ for plotting versus pixel coordinates; ‘tube-pixel’ for plotting versus tube and pixel index.

  • panel_name (str) – Name of the double panel detector array. If None, plots will be generated for all arrays.

  • figure_kwargs (str) – Optional arguments to matplotlib.pyplot.figure

  • imshow_kwargs (dict) – Optional arguments to matplotlib.axes.Axes.imshow

drtsans.plots.api.plot_i1d(workspaces, filename, log_scale=True, backend: str = 'd3', errorbar_kwargs=None, **kwargs)[source]

Save a plot representative of the supplied workspaces

Parameters:
  • workspaces (list, tuple, IQmod, I1DAnnular) – A collection of IQmod or I1DAnnular workspaces to plot.

  • filename (str) – The name of the file to save to. For the MATPLOTLIB backend, the type of file is determined from the file extension

  • log_scale (bool) – If true will set the pertinent axes to logarithmic, otherwise leave them as linear

  • backend – Which backend to save the file using

  • errorbar_kwargs (dict) – Optional arguments to matplotlib.axes.Axes.errorbar Can be a comma separated list for each workspace e.g. {'label':'main,wing,both', 'color':'r,b,g', 'marker':'o,v,.'}

  • kwargs (dict) – Additional key word arguments for matplotlib.axes.Axes

drtsans.plots.api.plotly_IQazimuthal(profile: IQazimuthal, title: str = '', q_min: float = None, q_max: float = None, wedges: List[Any] = None, symmetric_wedges: bool = True, log_scale: bool = True) str[source]

Generate a Plotly heatmap plot for an I(Qx, Qy) profile.

Parameters:
  • profile – The I(Qx, Qy) profile data to plot

  • title (str, optional) – Plot title. Will append suffix ‘(log scale)’ if log_scale is True

  • q_min (float, optional) – Minimum Q value for ring selection. If specified, all I(Q) with Q < q_min will be masked

  • q_max (float, optional) – Maximum Q value for ring selection. If specified, all I(Q) with Q > q_max will be masked

  • wedges (list of tuple, optional) – List of (angle_min, angle_max) tuples defining wedge regions in degrees. Both angles must be in the [-90, 270) range

  • symmetric_wedges (bool, optional) – If True, add wedges offset by 180 degrees for symmetry

  • log_scale (bool, optional) – If True, plot intensity on a logarithmic scale

Return type:

HTML div string containing the Plotly heatmap figure

Raises:

ValueError – If profile is not of type IQazimuthal

drtsans.plots.api.plotly_i1d(profiles: IQmod | List[IQmod], labels: str | List[str] = None, title: str = '', loglog: bool = True) str[source]

Generate a Plotly figure per 1D I(Q) profile.

This function serves as a dispatcher that validates the profile type and delegates to the appropriate plotting function. Currently only supports IQmod profiles.

Parameters:
  • profiles (IQmod or list of IQmod) – Single I(Q) profile or list of profiles to plot

  • labels (str or list of str, optional) – Label(s) for the profile(s). If not provided, no labels will be displayed

  • title (str, optional) – Plot title

  • loglog (bool, optional) – If True, use logarithmic scale for both axes. Default is True

Returns:

HTML div string containing the Plotly figure

Return type:

str

Raises:

Module contents

drtsans.plots.plot_I1DAnnular(workspaces, filename, logy=True, backend: str = 'd3', errorbar_kwargs=None, **kwargs)[source]

Save a plot representative of the supplied I(phi) workspaces

Parameters:
  • workspaces (list, tuple, I1DAnnular) – A collection of I1DAnnular workspaces to plot.

  • filename (str) – The name of the file to save to. For the MATPLOTLIB backend, the type of file is determined from the file extension

  • logy (bool) – If true will set the intensity axis to logarithmic, otherwise leave it as linear

  • backend – Which backend to save the file using

  • errorbar_kwargs (dict) – Optional arguments to matplotlib.axes.Axes.errorbar Can be a comma separated list for each workspace e.g. {'label':'main,wing,both', 'color':'r,b,g', 'marker':'o,v,.'}

  • kwargs (dict) – Additional key word arguments for matplotlib.axes.Axes

drtsans.plots.plot_IQazimuthal(workspace, filename, backend: str = 'd3', qmin: float = None, qmax: float = None, wedges: List[Any] = None, symmetric_wedges: bool = True, mask_alpha=0.6, imshow_kwargs: Dict = {}, **kwargs)[source]

Save a plot of I(Qx, Qy). If qmin is specified, all I(Q) with Q less than qmin will be masked in output plot. If qmax is specified, all I(Q) with Q greater than qmax will be masked in output plot. If wedges are specified, all I(Q) out side of wedges will be masked in output plot.

Parameters:
  • workspace (IQazimuthal) – The workspace (i.e., I(Qx, Qy)) to plot. This assumes the data is binned on a constant grid.

  • filename (str) – The name of the file to save to. For the MATPLOTLIB backend, the type of file is determined from the file extension

  • qmin (float) – minimum 1D Q for plotting selection area

  • qmax (float) – maximum 1D Q for plotting selection area

  • wedges (~list or None) – list of tuples (angle_min, angle_max) for the wedges. Select wedges to plot. Both numbers have to be in the [-90,270) range. It will add the wedge offset by 180 degrees dependent on symmetric_wedges

  • symmetric_wedges (bool) – Add the wedge offset by 180 degrees if True

  • mask_alpha (float) – Opacity for for selection area

  • backend – Which backend to save the file using

  • imshow_kwargs (~dict) – Optional arguments to matplotlib.axes.Axes.imshow e.g. {"norm": LogNorm()}

  • kwargs (~dict) – Additional key word arguments for matplotlib.axes.Axes

drtsans.plots.plot_IQmod(workspaces, filename, loglog=True, backend: str = 'd3', errorbar_kwargs=None, **kwargs)[source]

Save a plot representative of the supplied workspaces

Parameters:
  • workspaces (list, tuple, IQmod) – A collection of IQmod workspaces to plot.

  • filename (str) – The name of the file to save to. For the MATPLOTLIB backend, the type of file is determined from the file extension

  • loglog (bool) – If true will set both axis to logarithmic, otherwise leave them as linear

  • backend – Which backend to save the file using

  • errorbar_kwargs (dict) – Optional arguments to matplotlib.axes.Axes.errorbar Can be a comma separated list for each workspace e.g. {'label':'main,wing,both', 'color':'r,b,g', 'marker':'o,v,.'}

  • kwargs (dict) – Additional key word arguments for matplotlib.axes.Axes

drtsans.plots.plot_detector(input_workspace, filename=None, backend: str = 'd3', axes_mode='tube-pixel', panel_name=None, figure_kwargs={'figsize': (8, 6)}, imshow_kwargs={'norm': <matplotlib.colors.LogNorm object>})[source]

Save a 2D plot representative of the supplied workspace

Parameters:
  • input_workspace (str, MatrixWorkspace) – The workspace to plot

  • filename (str) – The name of the file to save to. For the MATPLOTLIB backend, the type of file is determined from the file extension

  • backend – Which backend to save the file using

  • axes_mode (str) – Plot intensities versus different axes. Options are: ‘xy’ for plotting versus pixel coordinates; ‘tube-pixel’ for plotting versus tube and pixel index.

  • panel_name (str) – Name of the double panel detector array. If None, plots will be generated for all arrays.

  • figure_kwargs (str) – Optional arguments to matplotlib.pyplot.figure

  • imshow_kwargs (dict) – Optional arguments to matplotlib.axes.Axes.imshow

drtsans.plots.plot_i1d(workspaces, filename, log_scale=True, backend: str = 'd3', errorbar_kwargs=None, **kwargs)[source]

Save a plot representative of the supplied workspaces

Parameters:
  • workspaces (list, tuple, IQmod, I1DAnnular) – A collection of IQmod or I1DAnnular workspaces to plot.

  • filename (str) – The name of the file to save to. For the MATPLOTLIB backend, the type of file is determined from the file extension

  • log_scale (bool) – If true will set the pertinent axes to logarithmic, otherwise leave them as linear

  • backend – Which backend to save the file using

  • errorbar_kwargs (dict) – Optional arguments to matplotlib.axes.Axes.errorbar Can be a comma separated list for each workspace e.g. {'label':'main,wing,both', 'color':'r,b,g', 'marker':'o,v,.'}

  • kwargs (dict) – Additional key word arguments for matplotlib.axes.Axes

drtsans.plots.plotly_IQazimuthal(profile: IQazimuthal, title: str = '', q_min: float = None, q_max: float = None, wedges: List[Any] = None, symmetric_wedges: bool = True, log_scale: bool = True) str[source]

Generate a Plotly heatmap plot for an I(Qx, Qy) profile.

Parameters:
  • profile – The I(Qx, Qy) profile data to plot

  • title (str, optional) – Plot title. Will append suffix ‘(log scale)’ if log_scale is True

  • q_min (float, optional) – Minimum Q value for ring selection. If specified, all I(Q) with Q < q_min will be masked

  • q_max (float, optional) – Maximum Q value for ring selection. If specified, all I(Q) with Q > q_max will be masked

  • wedges (list of tuple, optional) – List of (angle_min, angle_max) tuples defining wedge regions in degrees. Both angles must be in the [-90, 270) range

  • symmetric_wedges (bool, optional) – If True, add wedges offset by 180 degrees for symmetry

  • log_scale (bool, optional) – If True, plot intensity on a logarithmic scale

Return type:

HTML div string containing the Plotly heatmap figure

Raises:

ValueError – If profile is not of type IQazimuthal

drtsans.plots.plotly_i1d(profiles: IQmod | List[IQmod], labels: str | List[str] = None, title: str = '', loglog: bool = True) str[source]

Generate a Plotly figure per 1D I(Q) profile.

This function serves as a dispatcher that validates the profile type and delegates to the appropriate plotting function. Currently only supports IQmod profiles.

Parameters:
  • profiles (IQmod or list of IQmod) – Single I(Q) profile or list of profiles to plot

  • labels (str or list of str, optional) – Label(s) for the profile(s). If not provided, no labels will be displayed

  • title (str, optional) – Plot title

  • loglog (bool, optional) – If True, use logarithmic scale for both axes. Default is True

Returns:

HTML div string containing the Plotly figure

Return type:

str

Raises: