The widgets.silx_plot sub-package#

Package with subclassed silx widgets and actions.

class pydidas.widgets.silx_plot.PydidasMaskToolsWidget(parent: QWidget | None = None, plot: Plot2D | None = None, **kwargs: Any)#

Bases: MaskToolsWidget

A customized silx.gui.plot.MaskToolsWidget with larger buttons.

class pydidas.widgets.silx_plot.PydidasPlot1D(**kwargs: Any)#

Bases: Plot1D

A customized silx.gui.plot.Plot1D with support for pydidas Datasets.

clear_plot(clear_data: bool = True) None#

Clear the plot and remove all items.

Parameters:

clear_data (bool, optional) – Flag to remove all items from the stored data dictionary as well.

display_data(data: Dataset, **kwargs: Any) None#

Plot a pydidas dataset.

Parameters:
  • data (pydidas.core.Dataset) – The data to be plotted.

  • **kwargs (Any) –

    Additional keyword arguments to be passed to the silx plot method. Supported keywords are:

    resetzoombool, optional

    Flag to reset the zoom after plotting. The default is True.

    replacebool, optional

    Flag to clear the plot before adding new curves. The default is True.

    linewidthfloat, optional

    The line width for the curves. The default is 1.5.

    linestylestr, optional

    The line style for the curves. The default is ‘-‘.

    symbolstr or None, optional

    The symbol for the curves. The default is None.

    ylabelstr, optional

    The y-axis label. If not provided, it will be automatically generated from the data metadata.

    titlestr, optional

    The plot title.

    legendstr, optional

    The legend for the curve(s).

plot_data(data: ndarray, **kwargs: Any) None#

Plot a numpy ndarray.

This method supports both generic numpy ndarrays and pydidas Dataset instances. If a Dataset is provided, the plot_pydidas_dataset method is called.

Parameters:
  • data (numpy.ndarray) – The data to be plotted.

  • **kwargs (Any) –

    Additional keyword arguments to be passed to the silx plot method. Supported arguments are all those supported by silx Plot1D.addCurve, as well as:

    xnumpy.ndarray, optional

    The x values to be used for the plot. If not provided, the index of the data array will be used.

plot_pydidas_dataset(data: Dataset, **kwargs: Any) None#

Plot a pydidas dataset.

Parameters:
  • data (pydidas.core.Dataset) – The data to be plotted.

  • **kwargs (Any) –

    Additional keyword arguments to be passed to the silx plot method. Supported keywords are:

    resetzoombool, optional

    Flag to reset the zoom after plotting. The default is True.

    replacebool, optional

    Flag to clear the plot before adding new curves. The default is True.

    linewidthfloat, optional

    The line width for the curves. The default is 1.5.

    linestylestr, optional

    The line style for the curves. The default is ‘-‘.

    symbolstr or None, optional

    The symbol for the curves. The default is None.

    ylabelstr, optional

    The y-axis label. If not provided, it will be automatically generated from the data metadata.

    titlestr, optional

    The plot title.

    legendstr, optional

    The legend for the curve(s).

update_mpl_fonts() None#

Update the plot’s fonts.

class pydidas.widgets.silx_plot.PydidasPlot2D(**kwargs: Any)#

Bases: Plot2D, PydidasQsettingsMixin

A customized silx.gui.plot.Plot2D with an additional features.

Additional features are implemented through additional SilxActions which are added to the toolbar.

addImage(data: Dataset | ndarray, **kwargs: Any) None#

Add an image to the plot.

This method implements an additional dimensionality check before passing the image to the Plot2d.addImage method.

Parameters:
  • data (Dataset or np.ndarray) – The input data to be displayed.

  • **kwargs (Any) – Any supported Plot2d.addImage keyword arguments.

clear_plot() None#

Clear the plot and remove all items.

property default_unit: str#

The default unit for the plot axes.

Returns:

The default unit for the plot axes.

Return type:

str

display_data(data: Dataset, **kwargs: Any) None#

Plot a pydidas Dataset.

Parameters:
  • data (pydidas.core.Dataset) – The data to be plotted.

  • **kwargs (Any) – Additional keyword arguments to be passed to the silx plot method.

plot_data(data: Dataset | ndarray, **kwargs: Any) None#

Add an image to the plot.

This method implements an additional dimensionality check before passing the image to the Plot2d.addImage method.

Parameters:
  • data (Dataset or np.ndarray) – The input data to be displayed.

  • **kwargs (Any) – Any supported Plot2d.addImage keyword arguments.

plot_nonlinear_axes_image(data: Dataset, **kwargs: Any) None#

Add an image with non-linear axes to the plot.

This method implements an additional dimensionality check before passing the image to the Plot2d.addImage method.

Parameters:
  • data (Dataset) – The input data to be displayed.

  • **kwargs (Any) – Any supported Plot2d.addImage keyword arguments.

plot_pydidas_dataset(data: Dataset, **kwargs: Any) None#

Plot a pydidas Dataset.

Parameters:
  • data (pydidas.core.Dataset) – The data to be plotted.

  • **kwargs (Any) – Additional keyword arguments to be passed to the silx plot method.

update_cs_units(x_unit: str, y_unit: str) None#

Update the coordinate system units.

Note: Any changes to the CS transform will overwrite these settings.

Parameters:
  • x_unit (str) – The unit for the data x-axis.

  • y_unit (str) – The unit for the data y-axis

update_mpl_fonts() None#

Update the plot’s fonts. This is done by resetting the backend.

user_config_update(key: str, value: str) None#

Handle a user config update.

Parameters:
  • key (str) – The name of the updated key.

  • value – The new value of the updated key.

class pydidas.widgets.silx_plot.PydidasPlot2DwithIntegrationRegions(**kwargs: Any)#

Bases: PydidasPlot2D

An extended PydidasPlot2D which allows to show integration regions.

draw_circle(radius: float, legend: str, center: Point | None = None) None#

Draw a circle with the given radius and store it as the given legend.

Parameters:
  • radius (float) – The circle radius in pixels.

  • legend (str) – The shape’s legend for referencing it in the plot.

  • center (Point, optional) – The center of the circle. If None, this defaults to the DiffractionExperiment beamcenter. The default is None.

draw_integration_region(radial: tuple[float, float] | None, azimuthal: tuple[float, float] | None) None#

Draw the given integration region.

Parameters:
  • radial (tuple[float, float] | None) – The radial integration region. Use None for the full detector or a tuple with (r_inner, r_outer) in pixels to select a region.

  • azimuthal (tuple[float, float] | None) – The azimuthal integration region. Use None for the full detector or a tuple with (azi_start, azi_end) in radians for a region.

draw_line_from_beamcenter(chi: float, legend: str) None#

Draw a line from the beamcenter in the direction given by the angle chi.

Parameters:
  • chi (float) – The pointing angle, given in rad.

  • legend (str) – The reference legend entry for this line.

set_marker_color(color: str) None#

Set the new marker color.

Parameters:

color (str) – The marker color name.

class pydidas.widgets.silx_plot.PydidasPlotStack(**kwargs: Any)#

Bases: QStackedWidget

A stack with two plots for 1d and 2d data which selects the correct to display.

Parameters:

**kwargs (Any) –

Supported keyword arguments are:

parentQtWidgets.QWidget or None

The parent widget.

use_data_info_actionbool, optional

Flag to use the PydidasGetDataInfoAction to display information about a result datapoint. The default is False.

diffraction_expDiffractionExperiment, optional

The DiffractionExperiment instance to be used in the PydidasPlot2D for the coordinate system. The default is the generic DiffractionExperimentContext.

cs_transformbool, optional

Flag to enable coordinate system transformations.

clear_plot() None#

Clear all plots.

clear_plots() None#

Clear all plots.

plot_data(data: ndarray | Dataset, **kwargs: Any) None#

Plot the given data.

Parameters:
  • data (np.ndarray or Dataset) – The data to be plotted.

  • **kwargs (Any) – Any additional keywords to be passed to the plot.

resetZoom() None#

Reset the zoom on the current plot.