visualization

This module contains utility functions for visualization used across the package and which may be useful also for external applications.

clusterx.visualization.juview(plat, n=None)

Visualize structure object in Jupyter notebook

Parameters:

plat: any of Atoms(ASE), ParentLattice, Supercell, Structure, StructureSet

structure object to be plotted

n: integer or list of integer

If integer, plot the first n structures. If list, plot range of structures. If None, return all structures.

Return:

nglview display object

clusterx.visualization.plot_optimization_vs_number_of_clusters(clsel, xmin=None, xmax=None, ymin=None, ymax=None, yfactor=1.0, scale=1.0, show_yzero_axis=True, show_plot=True, yaxis_label='Errors', fig_fname=None, data_fname=None)

Plot cluster optimization with matplotlib

The plot shows the prediction and fitting errors as a function of the clusters pool size resulting from a cluster optimization done with a ClustersSelector object.

The range of cluster pool sizes in the x-axis is determined by nclmin (minimum size) and nclmax (maximum size)

Parameters:

clsel: ClustersSelector object

The ClustersSelector oject which was used for the cluster optimization.

xmin: integer (Default: None)

Minimum cluster size in x-axis.

xmax: integer (Default: None)

Maximum cluster size in x-axis.

yfactor: float (Default:1.0)

Multipliplicative factor for y-values. Useful to pass unit conversion factors.

scale: float (Default: 1.0)

Adjust this parameter to change font size, axes line width, and other details of the plot.

yaxis_label: string (Default: “Errors”)

Label for the y-axis of the plot

clusterx.visualization.plot_optimization_vs_sparsity(clsel, xmin=None, xmax=None, ymin=None, ymax=None, xaxis_label='Sparsity', yaxis_label='Energy [arb. units]', show_plot=True, fname='plot_optimization_vs_sparsity')

Plot cluster optimization with matplotlib

The plot shows the prediction and fitting errors as a function of the

Parameters:

clsel: ClustersSelector object

The ClustersSelector oject which was used for the optimization to be plotted. sparsity parameter when the LASSO method is used.

clusterx.visualization.plot_predictions_vs_target(sset, cemodel, prop_name, scale=1.0, xaxis_label='Calculated energy [arb. units]', yaxis_label='Predicted energy [arb. units]')

Plot predictions versus target with matplotlib

The plot shows the prediction versus the target

Parameters:

sset: StructuresSet object cemodel: Model object prop_name: string

clusterx.visualization.plot_property(xvalues, yvalues, prop_name=None, xaxis_label=None, yaxis_label=None, show_plot=True, scale=1.0)

yvalues versus xvalues

clusterx.visualization.plot_property_vs_concentration(sset, site_type=0, sigma=1, cemodel=None, property_name=None, show_loo_predictions=True, sset_enum=None, properties_enum=None, concentrations_enum=None, sset_gss=None, show_plot=True, refs=None, scale=1.0, yaxis_label=None, yfactor=1.0, show_yzero_axis=True, data_fname=None, fig_fname=None)

Plot property values versus concentration and return dictionary with data

The call to this functions generates a plot with matplotlib. It also returns a dictionary with the data used to generate the plot. This is useful in the case that the user wants to format the plot in a different way, or to write the data to a file for postprocessing (in the case that only the data is neeed, set show_plot to False).

Parameters:

sset: StructuresSet object

The property values will be plotted for structures in sset.

site_type: integer

The x axis of the plot will indicate the fractional concentration for site type site_type

sigma: integer

The x axis of the plot will indicate the fractional concentration for the atomic species sigma in site type site_type

cemodel: Model object

If not None, the property values as predicted by cemodel will be depicted.

refs: 1D Array containing two float (optional, default: None)

the values of a reference energy at concentrations 0 and 1.

property_name: string

If not None, the calculated property property_name will be extracted from the sset and depicted in the plot. If cemodel is not None as well, then both predicted and calculated data are plot.

show_loo_predictions: Boolean

If true, show predicted properties corresponding to leave-one-out CV. That is, the predictions for the left-out samples in the CV procedure are also plotted.

Returns:

Returns a dictionary with the data used to build the plot, with the following elements:

  • data["concentration"]: Array of floats. The x-axis of the plot, containing the concentration of the substitutional species.

  • data["property"]: Array of floats, same lenght as data["concentration"]. Contains the values returned by sset.get_property_values(property_name = property_name).

  • data["predicted-property"]: The prediced properties with cemodel.

  • data["predicted-property-cv"]: The prediced properties with cemodel on CV.

  • data["concentration-enum"]: Concentrations for enumeration.

  • data["predicted-property-enum"]: Predicted values for enumeration.

  • data["concentration-gss"]: Concentrations for ground-state search.

  • data["predicted-property-gss"]: Predicted values for ground-state-search.

Depending on the arguments to the call to plot_property_vs_concentration, some of the returned dictionary elements may be missing.