openmc.Plots

class openmc.Plots(plots=None)[source]

Collection of Plots used for an OpenMC simulation.

This class corresponds directly to the plots.xml input file. It can be thought of as a normal Python list where each member is a Plot. It behaves like a list as the following example demonstrates:

>>> xz_plot = openmc.Plot()
>>> big_plot = openmc.Plot()
>>> small_plot = openmc.Plot()
>>> p = openmc.Plots((xz_plot, big_plot))
>>> p.append(small_plot)
>>> small_plot = p.pop()
Parameters

plots (Iterable of openmc.Plot) – Plots to add to the collection

append(plot)[source]

Append plot to collection

Parameters

plot (openmc.Plot) – Plot to append

colorize(geometry, seed=1)[source]

Generate a consistent color scheme for each domain in each plot.

This routine may be used to generate random, reproducible color schemes. The colors generated are based upon cell/material IDs in the geometry. The color schemes will be consistent for all plots in “plots.xml”.

Parameters
  • geometry (openmc.Geometry) – The geometry for which the plots are defined

  • seed (Integral) – The random number seed used to generate the color scheme

export_to_xml(path='plots.xml')[source]

Export plot specifications to an XML file.

Parameters

path (str) – Path to file to write. Defaults to ‘plots.xml’.

classmethod from_xml(path='plots.xml')[source]

Generate plots collection from XML file

Parameters

path (str, optional) – Path to plots XML file

Returns

Plots collection

Return type

openmc.Plots

highlight_domains(geometry, domains, seed=1, alpha=0.5, background='gray')[source]

Use alpha compositing to highlight one or more domains in the plot.

This routine generates a color scheme and applies alpha compositing to make all domains except the highlighted ones appear partially transparent.

Parameters
  • geometry (openmc.Geometry) – The geometry for which the plot is defined

  • domains (Iterable of openmc.Cell or openmc.Material) – A collection of the domain IDs to highlight in the plot

  • seed (int) – The random number seed used to generate the color scheme

  • alpha (float) – The value between 0 and 1 to apply in alpha compisiting

  • background (3-tuple of int or str) – The background color to apply in alpha compisiting

insert(index, plot)[source]

Insert plot before index

Parameters