mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
adding optional outline to plots
This commit is contained in:
parent
ae615c02d9
commit
95a07b8085
1 changed files with 17 additions and 1 deletions
|
|
@ -295,7 +295,7 @@ class Universe(UniverseBase):
|
|||
|
||||
def plot(self, origin=(0., 0., 0.), width=(1., 1.), pixels=(200, 200),
|
||||
basis='xy', color_by='cell', colors=None, seed=None,
|
||||
openmc_exec='openmc', axes=None, **kwargs):
|
||||
openmc_exec='openmc', axes=None, outline=False, **kwargs):
|
||||
"""Display a slice plot of the universe.
|
||||
|
||||
Parameters
|
||||
|
|
@ -332,6 +332,10 @@ class Universe(UniverseBase):
|
|||
**kwargs
|
||||
Keyword arguments passed to :func:`matplotlib.pyplot.imshow`
|
||||
|
||||
.. versionadded:: 0.13.4
|
||||
outline : bool
|
||||
Whether outlines between color boundaries should be drawn
|
||||
|
||||
Returns
|
||||
-------
|
||||
matplotlib.image.AxesImage
|
||||
|
|
@ -396,6 +400,18 @@ class Universe(UniverseBase):
|
|||
height = pixels[0]*px/(params.top - params.bottom)
|
||||
fig.set_size_inches(width, height)
|
||||
|
||||
if outline:
|
||||
combined_rgb = np.sum(img, 2)
|
||||
|
||||
axes.contour(
|
||||
combined_rgb.reshape(img.shape[0], img.shape[1]),
|
||||
origin="upper",
|
||||
colors="k",
|
||||
linestyles="solid",
|
||||
linewidths=1,
|
||||
extent=(x_min, x_max, y_min, y_max),
|
||||
)
|
||||
|
||||
# Plot image and return the axes
|
||||
return axes.imshow(img, extent=(x_min, x_max, y_min, y_max), **kwargs)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue