Skip to content

Commit

Permalink
Added properties to histogram and scatter viewer states to control th…
Browse files Browse the repository at this point in the history
…e percentile to use when determining the min/max in reset_limits, and also added a property to the histogram state to determine whether bins are updated when calling reset_limits.
  • Loading branch information
astrofrog committed Oct 31, 2023
1 parent 4de2cfd commit 0aa1f32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 7 additions & 2 deletions glue/viewers/histogram/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class HistogramViewerState(MatplotlibDataViewerState):
common_n_bin = DDCProperty(True, docstring='The number of bins to use for '
'all numerical components')

x_limits_percentile = DDCProperty(100, docstring="Percentile to use when automatically determining x limits")

update_bins_on_reset_limits = DDCProperty(True, docstring="Whether to update the bins to match the view when resetting limits")

def __init__(self, **kwargs):

super(HistogramViewerState, self).__init__()
Expand Down Expand Up @@ -67,9 +71,10 @@ def _reset_x_limits(self, *args):
if self.x_att is None:
return
with delay_callback(self, 'hist_x_min', 'hist_x_max', 'x_min', 'x_max', 'x_log'):
self.x_lim_helper.percentile = 100
self.x_lim_helper.percentile = self.x_limits_percentile
self.x_lim_helper.update_values(force=True)
self.update_bins_to_view()
if self.update_bins_on_reset_limits:
self.update_bins_to_view()

def reset_limits(self):
self._reset_x_limits()
Expand Down
7 changes: 5 additions & 2 deletions glue/viewers/scatter/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class ScatterViewerState(MatplotlibDataViewerState):
plot_mode = DDSCProperty(docstring="Whether to plot the data in cartesian, polar or another projection")
angle_unit = DDSCProperty(docstring="Whether to use radians or degrees for any angular coordinates")

x_limits_percentile = DDCProperty(100, docstring="Percentile to use when automatically determining x limits")
y_limits_percentile = DDCProperty(100, docstring="Percentile to use when automatically determining y limits")

def __init__(self, **kwargs):

super(ScatterViewerState, self).__init__()
Expand Down Expand Up @@ -70,13 +73,13 @@ def __init__(self, **kwargs):
def _reset_x_limits(self, *args):
if self.x_att is None:
return
self.x_lim_helper.percentile = 100
self.x_lim_helper.percentile = self.x_limits_percentile
self.x_lim_helper.update_values(force=True)

def _reset_y_limits(self, *args):
if self.y_att is None:
return
self.y_lim_helper.percentile = 100
self.y_lim_helper.percentile = self.y_limits_percentile
self.y_lim_helper.update_values(force=True)

def reset_limits(self):
Expand Down

0 comments on commit 0aa1f32

Please sign in to comment.