Check out the Hyperspy Workshop May 13-17, 2024 Online

plot_diffraction_vectors#

DiffractionVectors.plot_diffraction_vectors(xlim=1.0, ylim=1.0, unique_vectors=None, distance_threshold=0.01, method='distance_comparison', min_samples=1, image_to_plot_on=None, image_cmap='gray', plot_label_colors=False, distance_threshold_all=0.005)[source]#

Plot the unique diffraction vectors.

Parameters:
  • xlim (float) – The maximum x coordinate to be plotted.

  • ylim (float) – The maximum y coordinate in reciprocal Angstroms to be plotted.

  • unique_vectors (DiffractionVectors, optional) – The unique vectors to be plotted (optional). If not given, the unique vectors will be found by get_unique_vectors.

  • distance_threshold (float, optional) – The minimum distance in reciprocal Angstroms between diffraction vectors for them to be considered unique diffraction vectors. Will be passed to get_unique_vectors if no unique vectors are given.

  • method (str) – The method to use to determine unique vectors, if not given. Valid methods are ‘strict’, ‘distance_comparison’ and ‘DBSCAN’. ‘strict’ returns all vectors that are strictly unique and corresponds to distance_threshold=0. ‘distance_comparison’ checks the distance between vectors to determine if some should belong to the same unique vector, and if so, the unique vector is iteratively updated to the average value. ‘DBSCAN’ relies on the DBSCAN [1] clustering algorithm, and uses the Eucledian distance metric.

  • min_samples (int, optional) – The minimum number of not identical vectors within one cluster for it to be considered a core sample, i.e. to not be considered noise. Will be passed to get_unique_vectors if no unique vectors are given. Only used if method==’DBSCAN’.

  • image_to_plot_on (BaseSignal, optional) – If provided, the vectors will be plotted on top of this image. The image must be calibrated in terms of offset and scale.

  • image_cmap (str, optional) – The colormap to plot the image in.

  • plot_label_colors (bool, optional) – If True (default is False), also the vectors contained within each cluster will be plotted, with colors according to their cluster membership. If True, the unique vectors will be calculated by get_unique_vectors. Requires on method==’DBSCAN’.

  • distance_threshold_all (float, optional) – The minimum distance, in calibrated units, between diffraction vectors inside one cluster for them to be plotted. Only used if plot_label_colors is True and requires method==’DBSCAN’.

Returns:

fig – The plot as a matplotlib figure.

Return type:

matplotlib figure