pymatgen.analysis.pourbaix.plotter module

class PourbaixPlotter(pourbaixdiagram, show_unstable=False)[source]

Bases: object

A plotter class for phase diagrams.

Parameters:
  • phasediagram – A PhaseDiagram object.
  • show_unstable – Whether unstable phases will be plotted as well as red crosses. Defaults to False.
domain_vertices(entry)[source]

Returns the vertices of the Pourbaix domain.

Parameters:entry – Entry for which domain vertices are desired
Returns:list of vertices
get_center(lines)[source]

Returns coordinates of center of a domain. Useful for labeling a Pourbaix plot.

Parameters:
  • lines – Lines corresponding to a domain
  • limits – Limits of Pourbaix diagram
Returns:

x,y coordinate of center of domain. If domain lies outside limits, center will lie on the boundary.

Return type:

center_x, center_y

get_distribution_corrected_center(lines, h2o_h_line=None, h2o_o_line=None, radius=None)[source]

Returns coordinates of distribution corrected center of a domain. Similar to get_center(), but considers the distance to the surronding lines that mostly affects the feeling of “center”. This function will also try avoid overalapping the text babel with H2O stability line if H2O stability line is provided. Useful for labeling a Pourbaix plot.

Parameters:
  • lines – Lines corresponding to a domain
  • limits – Limits of Pourbaix diagram
  • h2o_h_line – Hydrogen line of H2O stability
  • h2o_o_line – Oxygen line of H2O stablity
  • radius – Half height of the text label.
Returns:

x,y coordinate of center of domain. If domain lies outside limits, center will lie on the boundary.

Return type:

center_x, center_y

get_pourbaix_mark_passive(limits=None, title='', label_domains=True, passive_entry=None)[source]

Color domains by element

get_pourbaix_plot(limits=None, title='', label_domains=True)[source]

Plot Pourbaix diagram.

Parameters:limits – 2D list containing limits of the Pourbaix diagram of the form [[xlo, xhi], [ylo, yhi]]
Returns:matplotlib plot object
Return type:plt
get_pourbaix_plot_colorfill_by_domain_name(limits=None, title='', label_domains=True, label_color='k', domain_color=None, domain_fontsize=None, domain_edge_lw=0.5, bold_domains=None, cluster_domains=(), add_h2o_stablity_line=True, add_center_line=False, h2o_lw=0.5, fill_domain=True, width=8, height=None, font_family='Times New Roman')[source]

Color domains by the colors specific by the domain_color dict

Parameters:
  • limits – 2D list containing limits of the Pourbaix diagram of the form [[xlo, xhi], [ylo, yhi]]
  • lable_domains (Bool) – whether add the text lable for domains
  • label_color (str) – color of domain lables, defaults to be black
  • domain_color (dict) – colors of each domain e.g {“Al(s)”: “#FF1100”}. If set to None default color set will be used.
  • domain_fontsize (int) – Font size used in domain text labels.
  • domain_edge_lw (int) – line width for the boundaries between domains.
  • bold_domains (list) – List of domain names to use bold text style for domain lables. If set to False, no domain will be bold.
  • cluster_domains (list) – List of domain names in cluster phase
  • add_h2o_stablity_line (Bool) – whether plot H2O stability line
  • add_center_line (Bool) – whether plot lines shows the center coordinate
  • h2o_lw (int) – line width for H2O stability line and center lines
  • fill_domain (bool) – a version without color will be product if set to False.
  • width (float) – Width of plot in inches. Defaults to 8in. height (float): Height of plot in inches. Defaults to width * golden ratio.
  • font_family (str) – Font family of the labels
get_pourbaix_plot_colorfill_by_element(limits=None, title='', label_domains=True, element=None)[source]

Color domains by element

legend(label_unstable=False, legend_file='')[source]
plot_chempot_range_map(limits=None, title='', filename='')[source]
plot_planes()[source]

Plot the free energy facets as a function of pH and V

plot_pourbaix(limits=None, title='', filename='', label_domains=True)[source]
pourbaix_hull_plot_data

Pourbaix diagram convex hull data.

Returns:(lines, stable_entries, unstable_entries) - lines is a list of list of coordinates for lines in the PD. - stable_entries is a {coordinate : entry} for each stable node in the phase diagram. (Each coordinate can only have one stable phase) - unstable_entries is a {entry: coordinates} for all unstable nodes in the phase diagram.
pourbaix_plot_data(limits=None)[source]

Get data required to plot Pourbaix diagram.

Parameters:limits – 2D list containing limits of the Pourbaix diagram of the form [[xlo, xhi], [ylo, yhi]]
Returns:stable_entries, unstable_entries stable_entries: dict of lines. The keys are Pourbaix Entries, and lines are in the form of a list unstable_entries: list of unstable entries
print_name(entry)[source]

Print entry name if single, else print multientry

show(label_stable=True, label_unstable=False, filename='')[source]

Draws the convex hull diagram using Matplotlib and show it.

write_image(plt, stream, image_format='svg')[source]

Writes the phase diagram to an image in a stream.

Parameters:
  • plt – matplotlib plot
  • stream – stream to write to. Can be a file stream or a StringIO stream.
  • image_format – format for image. Can be any of matplotlib supported formats. Defaults to svg for best results for vector graphics.
latexify_ion(formula)[source]