Skip to content

Commit

Permalink
Don't roll our own
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen committed Nov 10, 2023
1 parent 9120753 commit 2909959
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 1 addition & 5 deletions jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,17 +641,13 @@ def apply_RGB_presets(self):
if n_visible > 5:
cmap = matplotlib.colormaps['gist_rainbow'].resampled(n_visible)

def _rgb_to_hex(rgb):
rgb = [int(x * 255) for x in rgb]
return f"#{rgb[0]:02x}{rgb[1]:02x}{rgb[2]:02x}{rgb[3]:02x}"

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

self.stretch_function_value = "arcsinh"
self.stretch_preset_value = 99
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,6 @@ def _rgb_to_hex(rgb):
else:
assert po.stretch_function.value == "arcsinh"
assert po.stretch_preset.value == 99
assert po.image_color.value == _rgb_to_hex(colorbar_colors(color_ind))
assert po.image_color.value == matplotlib.colors.to_hex(colorbar_colors(color_ind),
keep_alpha=True)
color_ind += 1

0 comments on commit 2909959

Please sign in to comment.