Skip to content

Commit

Permalink
Make sure all layer artist properties that need to be updated followi…
Browse files Browse the repository at this point in the history
…ng change to plot_mode are updated before attempting to draw
  • Loading branch information
astrofrog committed Dec 4, 2024
1 parent 91e2421 commit fc5e9ed
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions glue/viewers/scatter/viewer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from echo import delay_callback

from glue.core.subset import roi_to_subset_state
from glue.core.util import update_ticks
from glue.core.roi_pretransforms import FullSphereLongitudeTransform, ProjectionMplTransform, RadianTransform
Expand Down Expand Up @@ -30,12 +32,6 @@ def setup_callbacks(self):
self.state.add_callback('y_axislabel', self._update_polar_ticks)
self._update_axes()

def limits_to_mpl(self, *args):
# These projections throw errors if we try to set the limits
if self.state.plot_mode in ['aitoff', 'hammer', 'lambert', 'mollweide']:
return
super().limits_to_mpl(*args)

def _update_ticks(self, *args):
radians = hasattr(self.state, 'angle_unit') and self.state.angle_unit == 'radians'
if self.state.x_att is not None:
Expand Down Expand Up @@ -71,9 +67,10 @@ def _update_projection(self, *args):
_, self.axes = init_mpl(self.figure, projection=self.state.plot_mode)
for layer in self.layers:
layer._set_axes(self.axes)
layer.state.vector_mode = 'Cartesian'
layer.state._update_points_mode()
layer.update()
with delay_callback(layer.state, 'vector_mode'):
layer.state.vector_mode = 'Cartesian'
layer.state._update_points_mode()
layer.update()
self.axes.callbacks.connect('xlim_changed', self.limits_from_mpl)
self.axes.callbacks.connect('ylim_changed', self.limits_from_mpl)
self.update_x_axislabel()
Expand Down Expand Up @@ -197,3 +194,9 @@ def __init__(self, session, parent=None, state=None):
proj = None if not state or not state.plot_mode else state.plot_mode
SimpleMatplotlibViewer.__init__(self, session, parent=parent, state=state, projection=proj)
MatplotlibScatterMixin.setup_callbacks(self)

def limits_to_mpl(self, *args):
# These projections throw errors if we try to set the limits
if self.state.plot_mode in ['aitoff', 'hammer', 'lambert', 'mollweide']:
return
super().limits_to_mpl(*args)

0 comments on commit fc5e9ed

Please sign in to comment.