Skip to content

Commit

Permalink
[vis] Fix Plotly cmap interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed Nov 29, 2024
1 parent cc78663 commit 87ca4ce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions phi/vis/_dash/_plotly_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,10 @@ def get_color_interpolation(val, cm_arr):
center = cm_arr[cm_arr[:, 0] == val][-1]
else:
offset_positions = cm_arr[:, 0] - val
color1 = cm_arr[numpy.argmax(offset_positions[offset_positions < 0])] # largest value smaller than control
color2 = cm_arr[numpy.argmin(offset_positions[offset_positions > 0])] # smallest value larger than control
below = offset_positions[offset_positions < 0]
color1 = cm_arr[numpy.argmax(below)] if below.size > 0 else cm_arr[0] # largest value smaller than control
above = offset_positions[offset_positions > 0]
color2 = cm_arr[numpy.argmin(above)] if above.size > 0 else cm_arr[-1] # smallest value larger than control
if color1[0] == color2[0]:
center = color1
else:
Expand Down

0 comments on commit 87ca4ce

Please sign in to comment.