landau.plot

landau.plot.plot_1d_T_phase_diagram(df, ax=None, mark_transitions=True, show=True, reference_phase=None, top_labels=True, side_labels=True, ylim=None, top_label_rotation='horizontal', color_override=None)[source]

Plots a one-dimensional equipotential phase diagram as a function of temperature.

Parameters:
  • df (pandas.DataFrame) – Input data containing columns for temperature (‘T’), semi-grandcanonical potential (‘phi’), phase name (‘phase’), and optionally a ‘border’ column indicating phase transition.

  • ax (matplotlib.axes.Axes, optional) – Existing matplotlib Axes to plot on. If None, a new figure and axes are created.

  • mark_transitions (bool, optional) – If True, all transition temperatures are marked on the plot. Defaults to True.

  • reference_phase (str, optional) – If given, subtract this phase’s potential from all other phases before plotting so that the reference phase lies at zero throughout.

  • top_labels (bool, optional) – If True, label the stable phase of each segment near the top of the axis. Defaults to True.

  • side_labels (bool, optional) – If True, remove the default seaborn legend and label every phase at the right end of its line instead. Defaults to True.

  • ylim (tuple or float, optional) – If given, applied like matplotlib.pyplot.ylim(). A scalar is treated as (None, ylim) (upper bound only). It also bounds the side-label stack: a label whose line end is above the window is moved to a mirrored stack on the left, and a phase whose line is pushed entirely out of view is not labelled.

  • top_label_rotation (str or float, optional) – Rotation of the top stable-phase labels: "horizontal" (default), "vertical" or an angle in degrees. Vertical labels fit stable windows too narrow for the horizontal name.

  • color_override (dict, optional) – dict[name -> color] overriding phase colours, as in get_phase_colors().

Returns:

The Axes object with the phase diagram plot.

Return type:

matplotlib.axes.Axes

landau.plot.plot_1d_mu_phase_diagram(df, ax=None, show=True, mark_transitions=True, reference_phase=None, top_labels=True, side_labels=True, ylim=None, element=None, top_label_rotation='horizontal', color_override=None)[source]

Plot a one dimensional isothermal phase diagram of the semi-grandcanonical potential as function of the chemical potential difference.

Parameters:
  • df (pandas.DataFrame) – Input data containing columns for chemical potential difference (‘mu’), semi-grandcanonical potential (‘phi’), phase name (‘phase’), stability (‘stable’), and optionally a ‘border’ column indicating phase transition.

  • ax (matplotlib.axes.Axes, optional) – Existing matplotlib Axes to plot on. If None, a new figure and axes are created.

  • mark_transitions (bool, optional) – If True, all transition temperatures are marked on the plot. Defaults to True.

  • reference_phase (str, optional) – If given, subtract this phase’s potential from all other phases before plotting so that the reference phase lies at zero throughout.

  • top_labels (bool, optional) – If True, label the stable phase of each segment near the top of the axis. Defaults to True.

  • side_labels (bool, optional) – If True, remove the default seaborn legend and label every phase at the right end of its line instead. Defaults to True.

  • ylim (tuple or float, optional) – If given, applied like matplotlib.pyplot.ylim(). A scalar is treated as (None, ylim) (upper bound only). It also bounds the side-label stack: a label whose line end is above the window is moved to a mirrored stack on the left, and a phase whose line is pushed entirely out of view is not labelled.

  • element (str, optional) – Name of the element whose chemical potential difference is scanned. If given, it subscripts the Δμ in the x label and in the transition annotations.

  • top_label_rotation (str or float, optional) – Rotation of the top stable-phase labels: "horizontal" (default), "vertical" or an angle in degrees. Vertical labels fit stable windows too narrow for the horizontal name.

  • color_override (dict, optional) – dict[name -> color] overriding phase colours, as in get_phase_colors().

Returns:

The Axes object with the phase diagram plot.

Return type:

matplotlib.axes.Axes

landau.plot.plot_mu_phase_diagram(df, alpha=0.1, element=None, color_override={}, triplepoints=None, transition_temperatures=False, poly_method=None, inline_legend=True, legend=True, ax=None, color_by=None, cmap=None, norm=None, colorbar=True)[source]
landau.plot.plot_phase_diagram(df, alpha=0.1, element=None, min_c_width=0.01, color_override={}, triplepoints=None, transition_temperatures=False, poly_method=None, variables=None, inline_legend=True, legend=True, ax=None, tielines=None, color_by=None, cmap=None, norm=None, colorbar=True)[source]

Style

landau.plot.style.theme sets the look of every landau plot. Its rc field holds a few rcParams: line width, tick and legend font sizes, the legend frame, figure size and resolution. Its other fields each style one kind of element. They hold matplotlib keyword arguments for colour, line style and font weight. Line widths, marker sizes and font sizes come from lines.linewidth, lines.markersize and font.size.

Field

Default

Styles

phase_boundary

{"edgecolor": "k"}

The outline of a phase field in a 2d diagram.

metastable

{"linestyle": "--"}

A phase’s curve where another phase is more stable, in 1d cuts and excess plots.

tie_line

{"color": "k", "alpha": 0.5, "linestyle": "-"}

A line between coexisting states: the three-phase isotherm of a c-T diagram, a common tangent of an excess plot.

transition_guide

{"color": "k", "alpha": 0.5, "linestyle": ":"}

The full-height line at a transition along a 1d cut.

transition_tick

{"direction": "in", "length": 6}

The tick on the top spine of a 1d cut at a transition.

invariant_marker

{"color": "k", "marker": "o"}

The dot at a coexisting state: a transition of a 1d cut, a triple point of a μ-T diagram, a tangent vertex.

line_phase_marker_scale

1.5

The size of a line-phase dot in an excess plot, in units of lines.markersize.

reference_line

{"color": ".5", "linestyle": "-"}

The zero line of an excess plot. It is axes.linewidth wide unless the field sets linewidth.

region_label

{"fontsize": "small", "fontweight": "bold"}

A phase name on the region where the phase is stable: a 2d field, a window along the top of a 1d cut.

curve_label

{"fontsize": "small"}

A phase name on its curve: the side labels of a 1d cut, the labels of an excess plot.

value_label

{"fontsize": "small"}

A number read off the plot: a transition temperature or chemical potential.

label_outline

{"linewidth": 3, "foreground": "white"}

The stroke behind every label.

Every plot function applies theme.rc while it runs. Your rcParams set everything else, fonts included. To change the look, change the theme:

from landau.plot.style import theme

theme.rc["lines.linewidth"] = 1.5      # validated like rcParams
del theme.rc["figure.figsize"]         # your rcParams set the figure size again
theme.tie_line["color"] = "tab:red"
theme.reset()                          # back to the defaults

styled() applies theme.rc to your own plots too:

from landau.plot.style import styled

with styled():
    plt.plot(x, y)
    plt.savefig("plot.png")            # the theme's resolution and tight bounding box

The look of every plot in landau.plot.

theme holds it. Its rc field holds rcParams: line width, tick and legend font sizes, the legend frame, figure size and resolution. Its other fields style one kind of plot element each, and set colour, line style and font weight only. Line widths, marker sizes and font sizes come from the rcParams lines.linewidth, lines.markersize and font.size.

Every plot function runs inside styled(), so it uses theme.rc instead of your rcParams for the keys in theme.rc. Your rcParams set everything else. Use styled on your own plots too:

with styled():
    plt.plot(x, y)

Change the theme on the object itself, not in rcParams:

theme.rc["lines.linewidth"] = 1.5    # validated like rcParams
del theme.rc["figure.figsize"]       # rcParams set the figure size again
theme.rc.clear()                     # rcParams set everything again
theme.tie_line["color"] = "tab:red"
theme.reset()                        # back to the defaults

The same element looks the same in every plot. A metastable branch is dashed. A tie line (the three-phase isotherm of a c-T diagram, the common tangent of an excess-free-energy plot) is a faded black line. A faded dotted line marks a transition along a 1d cut. Coexisting states are black dots of one size. A phase name in bold labels the region where that phase is stable; in regular weight it names a curve.

class landau.plot.style.Theme(rc=_default_rc(), phase_boundary=<factory>, metastable=<factory>, tie_line=<factory>, transition_guide=<factory>, invariant_marker=<factory>, line_phase_marker_scale=1.5, reference_line=<factory>, region_label=<factory>, curve_label=<factory>, value_label=<factory>, label_outline=<factory>, transition_tick=<factory>)[source]

The look of the landau plots; see the module docstring.

curve_label: dict

the side labels of a 1d cut, the labels of an excess-free-energy plot.

Type:

A phase name on its curve

invariant_marker: dict

a transition point of a 1d cut, a triple point of a mu-T diagram, a tangent vertex.

Type:

A coexisting state

label_outline: dict

The stroke behind every label, which keeps it legible over fills and lines.

line_phase_marker_scale: float = 1.5

A line phase drawn as one dot in an excess-free-energy plot, this many times lines.markersize wide.

line_phase_markersize()[source]

Marker size, in points, of a line phase drawn as one dot.

Return type:

float

metastable: dict

A phase’s curve where another phase is more stable.

phase_boundary: dict

The outline of a phase field in a 2d diagram.

rc: _Rc

rcParams applied inside styled(). Every key differs from matplotlib’s default, because a key at its default would only override your rcParams.

reference_line: dict

The zero line of an excess-free-energy plot; axes.linewidth wide unless it sets linewidth.

reference_line_kwargs()[source]

Line kwargs of a zero line: reference_line, axes.linewidth wide unless it sets a width.

Return type:

dict

region_label: dict

a 2d field, a stable window atop a 1d cut.

Type:

A phase name on the region where the phase is stable

reset()[source]

Restore every field to its default.

stability_dashes()[source]

Seaborn dashes= mapping for a style="stable" lineplot: solid when stable, else metastable.

Return type:

dict

tie_line: dict

the three-phase isotherm of a c-T diagram, a common tangent of an excess-free-energy plot.

Type:

A tie line

transition_guide: dict

The full-height line that marks a transition along a 1d cut.

transition_tick: dict

The tick on the top spine of a 1d cut that marks a transition; keyword arguments of tick_params.

value_label: dict

a transition temperature or chemical potential.

Type:

A number read off the plot

landau.plot.style.styled()[source]

Apply theme.rc on top of your rcParams; use as with styled(): or as the decorator @styled().

landau.plot.style.theme = Theme(rc=_Rc({'axes.titlesize': 'medium',      'figure.figsize': [6.0, 4.5],      'legend.fontsize': 'small',      'legend.frameon': False,      'lines.linewidth': 2.0,      'savefig.bbox': 'tight',      'savefig.dpi': 150.0,      'xtick.labelsize': 'small',      'ytick.labelsize': 'small'}), phase_boundary={'edgecolor': 'k'}, metastable={'linestyle': '--'}, tie_line={'color': 'k', 'alpha': 0.5, 'linestyle': '-'}, transition_guide={'color': 'k', 'alpha': 0.5, 'linestyle': ':'}, invariant_marker={'color': 'k', 'marker': 'o'}, line_phase_marker_scale=1.5, reference_line={'color': '.5', 'linestyle': '-'}, region_label={'fontsize': 'small', 'fontweight': 'bold'}, curve_label={'fontsize': 'small'}, value_label={'fontsize': 'small'}, label_outline={'linewidth': 3, 'foreground': 'white'}, transition_tick={'direction': 'in', 'length': 6})

The theme every plot function uses.