pycalphad.plot package

Subpackages

Submodules

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, tieline_color=(0, 1, 0, 1), tie_triangle_color=(1, 0, 0, 1), legend_generator=<function phase_legend>, **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

  • tieline_color (color) – A valid matplotlib color, such as a named color string, hex RGB string, or a tuple of RGBA components to set the color of the two phase region tielines. The default is an RGBA tuple for green: (0, 1, 0, 1).

  • tie_triangle_color (color) – A valid matplotlib color, such as a named color string, hex RGB string, or a tuple of RGBA components to set the color of the two phase region tielines. The default is an RGBA tuple for red: (1, 0, 0, 1).

  • legend_generator (Callable) – A function that will be called with the list of phases and will return legend labels and colors for each phase. By default pycalphad.plot.utils.phase_legend is used

  • kwargs (kwargs) – Passed to matplotlib.pyplot.scatter.

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 (v.MoleFraction) – instance of a pycalphad.variables.composition to plot on the x-axis. Must correspond to an independent condition.

  • y (v.MoleFraction) – instance of a pycalphad.variables.composition to plot on the y-axis. Must correspond to an independent condition.

  • eq_kwargs (optional) – Keyword arguments to equilibrium().

  • plot_kwargs (optional) – Keyword arguments to eqplot().

Return type:

A phase diagram as a figure.

Examples

None yet.

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'])

Module contents