openmc.Plot¶
- class openmc.Plot(plot_id=None, name='')[source]¶
Definition of a finite region of space to be plotted.
OpenMC is capable of generating two-dimensional slice plots, or three-dimensional voxel or projection plots. Colors that are used in plots can be given as RGB tuples, e.g. (255, 255, 255) would be white, or by a string indicating a valid SVG color.
- Parameters
- Variables
id (int) – Unique identifier
name (str) – Name of the plot
pixels (Iterable of int) – Number of pixels to use in each direction
filename (str) – Path to write the plot to
color_by ({'cell', 'material'}) – Indicate whether the plot should be colored by cell or by material
background (Iterable of int or str) – Color of the background
mask_components (Iterable of openmc.Cell or openmc.Material or int) – The cells or materials (or corresponding IDs) to mask
mask_background (Iterable of int or str) – Color to apply to all cells/materials listed in mask_components
show_overlaps (bool) – Indicate whether or not overlapping regions are shown
overlap_color (Iterable of int or str) – Color to apply to overlapping regions
colors (dict) – Dictionary indicating that certain cells/materials should be displayed with a particular color. The keys can be of type
Cell
,Material
, or int (ID for a cell/material).level (int) – Universe depth to plot at
width (Iterable of float) – Width of the plot in each basis direction
origin (tuple or list of ndarray) – Origin (center) of the plot
type ({'slice', 'voxel'}) – The type of the plot
basis ({'xy', 'xz', 'yz'}) – The basis directions for the plot
meshlines (dict) – Dictionary defining type, id, linewidth and color of a mesh to be plotted on top of a plot
- classmethod from_geometry(geometry, basis='xy', slice_coord=0.0)[source]¶
Return plot that encompasses a geometry.
- Parameters
geometry (openmc.Geometry) – The geometry to base the plot off of
basis ({'xy', 'xz', 'yz'}) – The basis directions for the plot
slice_coord (float) – The level at which the slice plot should be plotted. For example, if the basis is ‘xy’, this would indicate the z value used in the origin.
- classmethod from_xml_element(elem)[source]¶
Generate plot object from an XML element
- Parameters
elem (lxml.etree._Element) – XML element
- Returns
Plot object
- Return type
- 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 compositing
background (3-tuple of int or str) – The background color to apply in alpha compositing
- to_ipython_image(openmc_exec='openmc', cwd='.')[source]¶
Render plot as an image
This method runs OpenMC in plotting mode to produce a .png file.
Changed in version 0.13.0: The convert_exec argument was removed since OpenMC now produces .png images directly.