pycalphad.plot package#
Subpackages#
- pycalphad.plot.binary package
- Submodules
- pycalphad.plot.binary.compsets module
BinaryCompset
CompsetPair
CompsetPair.compsets
CompsetPair.a
CompsetPair.b
CompsetPair.phases
CompsetPair.unique_phases
CompsetPair.compositions
CompsetPair.temperature
CompsetPair.same_phase
CompsetPair.mean_composition
CompsetPair.max_composition
CompsetPair.min_composition
CompsetPair.Tdiscrepancy()
CompsetPair.pairwise_xdiscrepancy()
CompsetPair.xdiscrepancy()
CompsetPair.ydiscrepancy()
CompsetPair.ydiscrepancy_max()
find_two_phase_region_compsets()
get_compsets()
- pycalphad.plot.binary.map module
- pycalphad.plot.binary.plot module
- pycalphad.plot.binary.zpf_boundary_sets module
TwoPhaseRegion
ZPFBoundarySets
ZPFBoundarySets.components
ZPFBoundarySets.indep_comp_cond
ZPFBoundarySets.all_compsets
ZPFBoundarySets.two_phase_regions
ZPFBoundarySets.add_compsets()
ZPFBoundarySets.get_line_plot_boundaries()
ZPFBoundarySets.get_phases()
ZPFBoundarySets.get_scatter_plot_boundaries()
ZPFBoundarySets.rebuild_two_phase_regions()
- Module contents
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.triangular module#
Register a 'triangular'
projection with matplotlib to plot diagrams on
triangular axes.
Users should not have to instantiate the TriangularAxes class directly. Instead, the projection name can be passed as a keyword argument to matplotlib.
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> plt.gca(projection='triangular')
>>> plt.scatter(np.random.random(10), np.random.random(10))
- class pycalphad.plot.triangular.TriangularAxes(*args, **kwargs)[source]#
Bases:
Axes
A custom class for triangular projections.
- cla()[source]#
Hard-code axes limits to be on [0, 1] for both axes.
Warning: Limits not on [0, 1] may lead to clipping issues!
- drag_pan(button, key, x, y)[source]#
Called when the mouse moves during a pan operation.
- Parameters:
button (.MouseButton) – The pressed mouse button.
key (str or None) – The pressed key, if any.
x (float) – The mouse coordinates in display coords.
y (float) – The mouse coordinates in display coords.
Notes
This is intended to be overridden by new projection types.
- end_pan()[source]#
Called when a pan operation completes (when the mouse button is up.)
Notes
This is intended to be overridden by new projection types.
- get_xaxis_text1_transform(pad)[source]#
- Returns:
transform (Transform) – The transform used for drawing x-axis labels, which will add pad_points of padding (in points) between the axis and the label. The x-direction is in data coordinates and the y-direction is in axis coordinates
valign ({‘center’, ‘top’, ‘bottom’, ‘baseline’, ‘center_baseline’}) – The text vertical alignment.
halign ({‘center’, ‘left’, ‘right’}) – The text horizontal alignment.
Notes
This transformation is primarily used by the ~matplotlib.axis.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]#
- Returns:
transform (Transform) – The transform used for drawing secondary x-axis labels, which will add pad_points of padding (in points) between the axis and the label. The x-direction is in data coordinates and the y-direction is in axis coordinates
valign ({‘center’, ‘top’, ‘bottom’, ‘baseline’, ‘center_baseline’}) – The text vertical alignment.
halign ({‘center’, ‘left’, ‘right’}) – The text horizontal alignment.
Notes
This transformation is primarily used by the ~matplotlib.axis.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 x-axis labels, ticks and gridlines. The x-direction is in data coordinates and the y-direction is in axis coordinates.
Note
This transformation is primarily used by the ~matplotlib.axis.Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.
- Parameters:
which ({'grid', 'tick1', 'tick2'}) –
- get_yaxis_text1_transform(pad)[source]#
- Returns:
transform (Transform) – The transform used for drawing y-axis labels, which will add pad_points of padding (in points) between the axis and the label. The x-direction is in axis coordinates and the y-direction is in data coordinates
valign ({‘center’, ‘top’, ‘bottom’, ‘baseline’, ‘center_baseline’}) – The text vertical alignment.
halign ({‘center’, ‘left’, ‘right’}) – The text horizontal alignment.
Notes
This transformation is primarily used by the ~matplotlib.axis.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]#
- Returns:
transform (Transform) – The transform used for drawing secondart y-axis labels, which will add pad_points of padding (in points) between the axis and the label. The x-direction is in axis coordinates and the y-direction is in data coordinates
valign ({‘center’, ‘top’, ‘bottom’, ‘baseline’, ‘center_baseline’}) – The text vertical alignment.
halign ({‘center’, ‘left’, ‘right’}) – The text horizontal alignment.
Notes
This transformation is primarily used by the ~matplotlib.axis.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 y-axis labels, ticks and gridlines. The x-direction is in axis coordinates and the y-direction is in data coordinates.
Note
This transformation is primarily used by the ~matplotlib.axis.Axis class, and is meant to be overridden by new kinds of projections that may need to place axis elements in different locations.
- Parameters:
which ({'grid', 'tick1', 'tick2'}) –
- name = 'triangular'#
- set(*, adjustable=<UNSET>, agg_filter=<UNSET>, alpha=<UNSET>, anchor=<UNSET>, animated=<UNSET>, aspect=<UNSET>, autoscale_on=<UNSET>, autoscalex_on=<UNSET>, autoscaley_on=<UNSET>, axes_locator=<UNSET>, axisbelow=<UNSET>, box_aspect=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, facecolor=<UNSET>, frame_on=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, mouseover=<UNSET>, navigate=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, prop_cycle=<UNSET>, rasterization_zorder=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, subplotspec=<UNSET>, title=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, xbound=<UNSET>, xlabel=<UNSET>, xlim=<UNSET>, xmargin=<UNSET>, xscale=<UNSET>, xticklabels=<UNSET>, xticks=<UNSET>, ybound=<UNSET>, ylabel=<UNSET>, ylim=<UNSET>, ymargin=<UNSET>, yscale=<UNSET>, yticklabels=<UNSET>, yticks=<UNSET>, zorder=<UNSET>)#
Set multiple properties at once.
Supported properties are
- Properties:
adjustable: {‘box’, ‘datalim’} agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None anchor: (float, float) or {‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, …} animated: bool aspect: {‘auto’, ‘equal’} or float autoscale_on: bool autoscalex_on: unknown autoscaley_on: unknown axes_locator: Callable[[Axes, Renderer], Bbox] axisbelow: bool or ‘line’ box_aspect: float or None clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None facecolor or fc: color figure: ~matplotlib.figure.Figure frame_on: bool gid: str in_layout: bool label: object mouseover: bool navigate: bool navigate_mode: unknown path_effects: list of .AbstractPathEffect picker: None or bool or float or callable position: [left, bottom, width, height] or ~matplotlib.transforms.Bbox prop_cycle: ~cycler.Cycler rasterization_zorder: float or None rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None subplotspec: unknown title: str transform: ~matplotlib.transforms.Transform url: str visible: bool xbound: (lower: float, upper: float) xlabel: str xlim: (left: float, right: float) xmargin: float greater than -0.5 xscale: unknown xticklabels: unknown xticks: unknown ybound: (lower: float, upper: float) ylabel: str ylim: (bottom: float, top: float) ymargin: float greater than -0.5 yscale: unknown yticklabels: unknown yticks: unknown zorder: float
- set_ylabel(ylabel, fontdict=None, labelpad=None, *, loc=None, **kwargs)[source]#
Set the label for the y-axis. Default rotation=60 degrees.
- Parameters:
ylabel (str) – The label text.
labelpad (float, default: None) – Spacing in points from the axes bounding box including ticks and tick labels.
loc ({‘bottom’, ‘center’, ‘top’}, default: yaxis.labellocation) – The label position. This is a high-level alternative for passing parameters y and horizontalalignment.
**kwargs (.Text properties) – .Text properties control the appearance of the label.
See also
text
Documents the properties supported by .Text.
- start_pan(x, y, button)[source]#
Called when a pan operation has started.
- Parameters:
x (float) – The mouse coordinates in display coords.
y (float) – The mouse coordinates in display coords.
button (.MouseButton) – The pressed mouse button.
Notes
This is intended to be overridden by new projection types.
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'])