pycalphad.plot package¶
Submodules¶
pycalphad.plot.binary module¶
The binary module enables plotting of binary isobaric phase diagrams.

pycalphad.plot.binary.
binplot
(dbf, comps, phases, conds, eq_kwargs=None, **plot_kwargs)[source]¶ Calculate the binary isobaric phase diagram. This function is a convenience wrapper around equilibrium() and eqplot().
Parameters:  dbf (Database) – Thermodynamic database containing the relevant parameters.
 comps (list) – Names of components to consider in the calculation.
 phases (list) – Names of phases to consider in the calculation.
 conds (dict) – Maps StateVariables to values and/or iterables of values. For binplot only one changing composition and one potential coordinate each is supported.
 eq_kwargs (optional) – Keyword arguments to equilibrium().
 plot_kwargs (optional) – Keyword arguments to eqplot().
Returns: Return type: A phase diagram as a figure.
Examples
None yet.
pycalphad.plot.eqplot module¶
The eqplot module contains functions for general plotting of the results of equilibrium calculations.

pycalphad.plot.eqplot.
eqplot
(eq, ax=None, x=None, y=None, z=None, tielines=True, **kwargs)[source]¶ Plot the result of an equilibrium calculation.
The type of plot is controlled by the degrees of freedom in the equilibrium calculation.
Parameters:  eq (xarray.Dataset) – Result of equilibrium calculation.
 ax (matplotlib.Axes) – Default axes used if not specified.
 x (StateVariable, optional) –
 y (StateVariable, optional) –
 z (StateVariable, optional) –
 tielines (bool) – If True, will plot tielines
 kwargs (kwargs) – Passed to matplotlib.pyplot.scatter.
Returns: Return type: matplotlib AxesSubplot
pycalphad.plot.ternary module¶
The ternary module enables plotting of ternary isobaric phase diagrams.

pycalphad.plot.ternary.
ternplot
(dbf, comps, phases, conds, x=None, y=None, eq_kwargs=None, **plot_kwargs)[source]¶ Calculate the ternary isothermal, isobaric phase diagram. This function is a convenience wrapper around equilibrium() and eqplot().
Parameters:  dbf (Database) – Thermodynamic database containing the relevant parameters.
 comps (list) – Names of components to consider in the calculation.
 phases (list) – Names of phases to consider in the calculation.
 conds (dict) – Maps StateVariables to values and/or iterables of values. For ternplot only one changing composition and one potential coordinate each is supported.
 x (Composition) – instance of a pycalphad.variables.composition to plot on the xaxis. Must correspond to an independent condition.
 y (Composition) – instance of a pycalphad.variables.composition to plot on the yaxis. Must correspond to an independent condition.
 eq_kwargs (optional) – Keyword arguments to equilibrium().
 plot_kwargs (optional) – Keyword arguments to eqplot().
Returns: Return type: A phase diagram as a figure.
Examples
None yet.
pycalphad.plot.triangular module¶

class
pycalphad.plot.triangular.
TriangularAxes
(*args, **kwargs)[source]¶ Bases:
matplotlib.axes._axes.Axes
A custom class for triangular projections.

drag_pan
(button, key, x, y)[source]¶ Called when the mouse moves during a pan operation.
button is the mouse button number:
 1: LEFT
 2: MIDDLE
 3: RIGHT
key is a “shift” key
x, y are the mouse coordinates in display coords.
Note
Intended to be overridden by new projection types.

end_pan
()[source]¶ Called when a pan operation completes (when the mouse button is up.)
Note
Intended to be overridden by new projection types.

get_xaxis_text1_transform
(pad)[source]¶ Get the transformation used for drawing xaxis labels, which will add the given amount of padding (in points) between the axes and the label. The xdirection is in data coordinates and the ydirection is in axis coordinates. Returns a 3tuple of the form:
(transform, valign, halign)
where valign and halign are requested alignments for the text.
Note
This transformation is primarily used by the
Axis
class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

get_xaxis_text2_transform
(pad)[source]¶ Get the transformation used for drawing the secondary xaxis labels, which will add the given amount of padding (in points) between the axes and the label. The xdirection is in data coordinates and the ydirection is in axis coordinates. Returns a 3tuple of the form:
(transform, valign, halign)
where valign and halign are requested alignments for the text.
Note
This transformation is primarily used by the
Axis
class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

get_xaxis_transform
(which='grid')[source]¶ Get the transformation used for drawing xaxis labels, ticks and gridlines. The xdirection is in data coordinates and the ydirection is in axis coordinates.
Note
This transformation is primarily used by the
Axis
class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

get_yaxis_text1_transform
(pad)[source]¶ Get the transformation used for drawing yaxis labels, which will add the given amount of padding (in points) between the axes and the label. The xdirection is in axis coordinates and the ydirection is in data coordinates. Returns a 3tuple of the form:
(transform, valign, halign)
where valign and halign are requested alignments for the text.
Note
This transformation is primarily used by the
Axis
class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

get_yaxis_text2_transform
(pad)[source]¶ Get the transformation used for drawing the secondary yaxis labels, which will add the given amount of padding (in points) between the axes and the label. The xdirection is in axis coordinates and the ydirection is in data coordinates. Returns a 3tuple of the form:
(transform, valign, halign)
where valign and halign are requested alignments for the text.
Note
This transformation is primarily used by the
Axis
class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

get_yaxis_transform
(which='grid')[source]¶ Get the transformation used for drawing yaxis labels, ticks and gridlines. The xdirection is in axis coordinates and the ydirection is in data coordinates.
Note
This transformation is primarily used by the
Axis
class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.

name
= 'triangular'¶

pycalphad.plot.utils module¶
The plot utils module contains some useful routines related to plotting.

pycalphad.plot.utils.
phase_legend
(phases)[source]¶ Build matplotlib handles for the plot legend.
Parameters: phases (list) – Names of the phases. Returns:  A tuple containing
 (1) A list of matplotlib handle objects
 (2) A dict mapping phase names to their RGB color on the plot
Examples
>>> legend_handles, colors = phase_legend(['FCC_A1', 'BCC_A2', 'LIQUID'])