diff --git a/openmc/geometry.py b/openmc/geometry.py index 165b7f1a282..82a3fe61c5c 100644 --- a/openmc/geometry.py +++ b/openmc/geometry.py @@ -734,3 +734,61 @@ def clone(self) -> Geometry: clone = deepcopy(self) clone.root_universe = self.root_universe.clone() return clone + + def plot(self, *args, **kwargs): + """Display a slice plot of the geometry. + + .. versionadded:: 0.13.4 + + Parameters + ---------- + origin : iterable of float + Coordinates at the origin of the plot. If left as None then the + bounding box center will be used to attempt to ascertain the origin. + Defaults to (0, 0, 0) if the bounding box is not finite + width : iterable of float + Width of the plot in each basis direction. If left as none then the + bounding box width will be used to attempt to ascertain the plot + width. Defaults to (10, 10) if the bounding box is not finite + pixels : Iterable of int or int + If iterable of ints provided, then this directly sets the number of + pixels to use in each basis direction. If int provided, then this + sets the total number of pixels in the plot and the number of pixels + in each basis direction is calculated from this total and the image + aspect ratio. + basis : {'xy', 'xz', 'yz'} + The basis directions for the plot + color_by : {'cell', 'material'} + Indicate whether the plot should be colored by cell or by material + colors : dict + Assigns colors to specific materials or cells. Keys are instances of + :class:`Cell` or :class:`Material` and values are RGB 3-tuples, RGBA + 4-tuples, or strings indicating SVG color names. Red, green, blue, + and alpha should all be floats in the range [0.0, 1.0], for example: + .. code-block:: python + # Make water blue + water = openmc.Cell(fill=h2o) + universe.plot(..., colors={water: (0., 0., 1.)) + seed : int + Seed for the random number generator + openmc_exec : str + Path to OpenMC executable. + axes : matplotlib.Axes + Axes to draw to + legend : bool + Whether a legend showing material or cell names should be drawn + legend_kwargs : dict + Keyword arguments passed to :func:`matplotlib.pyplot.legend`. + outline : bool + Whether outlines between color boundaries should be drawn + axis_units : {'km', 'm', 'cm', 'mm'} + Units used on the plot axis + **kwargs + Keyword arguments passed to :func:`matplotlib.pyplot.imshow` + Returns + ------- + matplotlib.axes.Axes + Axes containing resulting image + """ + + return self.root_universe.plot(*args, **kwargs)