From 59f9b77333710b26300afddd32d556aa00536564 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Tue, 17 Nov 2015 21:21:14 -0500 Subject: [PATCH 1/2] Fixed bug in Plot.colorize() for cell plots --- openmc/plots.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmc/plots.py b/openmc/plots.py index acc7d4d13c..e805e09d27 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -284,7 +284,7 @@ class Plot(object): if self.color is 'mat': domains = geometry.get_all_materials() else: - domains = geometry.get_all_materials() + domains = geometry.get_all_cells() # Set the seed for the random number generator np.random.seed(seed) @@ -295,7 +295,7 @@ class Plot(object): r = np.random.randint(0, 255) g = np.random.randint(0, 255) b = np.random.randint(0, 255) - self.col_spec[domain.id] = (r, g, b) + self.col_spec[domain] = (r, g, b) def get_plot_xml(self): From 4d3c97f6989ff385b09fbcc4d8e7f5e1bb70cdc4 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Wed, 18 Nov 2015 11:01:12 -0500 Subject: [PATCH 2/2] Made upper bound for random colors 256 per comments by @paulromano --- openmc/plots.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openmc/plots.py b/openmc/plots.py index e805e09d27..41254d832d 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -267,8 +267,8 @@ class Plot(object): This routine may be used to generate random, reproducible color schemes. The colors generated are based upon cell/material IDs in the geometry. - Params - ------ + Parameters + ---------- geometry : openmc.Geometry The geometry for which the plot is created seed : Integral @@ -292,9 +292,9 @@ class Plot(object): # Generate random colors for each feature self.col_spec = {} for domain in domains: - r = np.random.randint(0, 255) - g = np.random.randint(0, 255) - b = np.random.randint(0, 255) + r = np.random.randint(0, 256) + g = np.random.randint(0, 256) + b = np.random.randint(0, 256) self.col_spec[domain] = (r, g, b) @@ -393,8 +393,8 @@ class PlotsFile(object): The colors generated are based upon cell/material IDs in the geometry. The color schemes will be consistent for all plots in "plots.xml". - Params - ------ + Parameters + ---------- geometry : openmc.Geometry The geometry for which the plots are defined seed : Integral