Skip to content

Commit

Permalink
This is working now somehow
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen committed Jan 11, 2024
1 parent 876b82a commit 628f38c
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions jdaviz/configs/cubeviz/plugins/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,13 @@ def activate(self):
# Add extra y-axis to show on right hand side of spectrum viewer
if self._extra_axis not in self._spectrum_viewer.figure.axes:
self._spectrum_viewer.figure.axes.append(self._extra_axis)
#self._spectrum_viewer.figure.send_state()
# Create the mark for the preview spectrum
if self._mark is None:
scales = {}
scales['x'] = self._spectrum_viewer.native_marks[0].scales['x']
scales['y'] = bqplot.LinearScale()
self._mark = PluginLine(self._spectrum_viewer, visible=False, scales=scales)
self._spectrum_viewer.figure.marks = self._spectrum_viewer.figure.marks + [self._mark,]
self._spectrum_viewer.figure.marks = self._spectrum_viewer.figure.marks + [self._mark]
# Store these so we can revert to previous user-set zoom after preview view
sv_state = self._spectrum_viewer.state
self._previous_bounds = [sv_state.x_min, sv_state.x_max, sv_state.y_min, sv_state.y_max]
Expand All @@ -143,15 +142,15 @@ def on_mouse_move(self, data):
if data['event'] == 'mouseleave':
self._mark.visible = False
self._extra_axis.visible=False
self._extra_axis.send_state()
self._extra_axis.send_state("visible")
self._spectrum_viewer.figure.fig_margin['right'] = 10
self._spectrum_viewer.figure.send_state()
self._spectrum_viewer.figure.send_state("fig_margin")
#self._reset_spectrum_viewer_bounds()
return

elif data['event'] == 'mouseenter':
# Make room for the extra axis
self._spectrum_viewer.figure.fig_margin['right'] = 50
self._spectrum_viewer.figure.fig_margin['right'] = 80
self._extra_axis.visible = True

x = int(np.round(data['domain']['x']))
Expand All @@ -178,13 +177,6 @@ def on_mouse_move(self, data):
float_y_max = float(np.nanmax(y_values.value))
self._extra_axis.scale.min = float_y_min
self._extra_axis.scale.max = float_y_max
#self._extra_axis.scale = bqplot.LinearScale(min=float_y_min, max=float_y_max)
#self._extra_axis.tick_values = np.linspace(float_y_min, float_y_max, 8)
#tick_vals = np.linspace(float_y_min, float_y_max, 8)
#self._extra_axis.tick_labels = {i: str(tick_vals[i]) for i in range(len(tick_vals))}

#self._spectrum_viewer.state.y_max = np.nanmax(y_values.value) * 1.2
#self._spectrum_viewer.state.y_min = np.nanmin(y_values.value) * 0.8

self._extra_axis.send_state()
self._spectrum_viewer.figure.send_state()
self._extra_axis.send_state(["scale", "visible"])
self._spectrum_viewer.figure.send_state(["fig_margin", "axes"])

0 comments on commit 628f38c

Please # to comment.