Skip to content

Commit

Permalink
Don't hard code numbers in the conditional statements
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen committed Nov 13, 2023
1 parent bb9e0a8 commit 786ce7a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,13 @@ def apply_RGB_presets(self):
if n_visible > 2:
default_opacity = 1 / math.log2(n_visible)
# Sample along a colormap if we have too many layers
if n_visible > 5:
if n_visible > len(preset_colors):
cmap = matplotlib.colormaps['gist_rainbow'].resampled(n_visible)

for i in range(n_visible):
self.layer_selected = visible_layers[i]
self.image_opacity_value = default_opacity
if n_visible < 6:
if n_visible <= len(preset_colors):
self.image_color_value = preset_colors[i]
else:
self.image_color_value = matplotlib.colors.to_hex(cmap(i), keep_alpha=True)
Expand Down

0 comments on commit 786ce7a

Please sign in to comment.