This module contains utility functions for visualization used across the package and which may be useful also for external applications.
Visualize structure object in Jupyter notebook
Parameters:
plat
: any of Atoms(ASE), ParentLattice, Supercell, Structure, StructureSetstructure object to be plotted
n
: integer or list of integerIf integer, plot the first n
structures. If list, plot range of structures.
If None
, return all structures.
Return:
nglview display object
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 objectThe 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
Plot cluster optimization with matplotlib
The plot shows the prediction and fitting errors as a function of the
Parameters:
clsel
: ClustersSelector objectThe ClustersSelector oject which was used for the optimization to be plotted. sparsity parameter when the LASSO method is used.
Plot predictions versus target with matplotlib
The plot shows the prediction versus the target
Parameters:
sset
: StructuresSet object
cemodel
: Model object
prop_name
: string
yvalues versus xvalues
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 objectThe property values will be plotted for structures in sset
.
site_type
: integerThe x axis of the plot will indicate the fractional concentration for
site type site_type
sigma
: integerThe x axis of the plot will indicate the fractional concentration for
the atomic species sigma
in site type site_type
cemodel
: Model objectIf 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
: stringIf 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
: BooleanIf 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 asdata["concentration"]
. Contains the values returned bysset.get_property_values(property_name = property_name)
.
data["predicted-property"]
: The prediced properties withcemodel
.
data["predicted-property-cv"]
: The prediced properties withcemodel
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.