Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Histogram bin size and limits #2309

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class PlotOptions(PluginTemplateMixin):
stretch_vmax_sync = Dict().tag(sync=True)

stretch_hist_zoom_limits = Bool().tag(sync=True)
stretch_hist_nbins = Int().tag(sync=True)
javerbukh marked this conversation as resolved.
Show resolved Hide resolved
stretch_histogram = Any().tag(sync=True, **widget_serialization)

subset_visible_value = Bool().tag(sync=True)
Expand Down Expand Up @@ -599,6 +600,7 @@ def _update_stretch_histogram(self, msg={}):
label='density')]

self.bqplot_figs_resize = [self.stretch_histogram]
self.stretch_hist_nbins = 25

else:
hist_mark = self.stretch_histogram.marks[0]
Expand Down Expand Up @@ -638,3 +640,21 @@ def _remove_histogram_marks(self):
return
self.stretch_histogram.marks = [mark for mark in self.stretch_histogram.marks
if not isinstance(mark, HistogramMark)]

@observe("stretch_hist_nbins")
def set_histogram_bin_size(self, msg):
if self.stretch_histogram is None or msg['new'] < 1:
return
self.stretch_histogram.marks[0].bins = msg['new']

def set_histogram_x_limits(self, x_min, x_max):
if x_min:
self.stretch_histogram.axes[0].scale.min = x_min
if x_max:
self.stretch_histogram.axes[0].scale.max = x_max

def set_histogram_y_limits(self, y_min, y_max):
if y_min:
self.stretch_histogram.axes[1].scale.min = y_min
if y_max:
self.stretch_histogram.axes[1].scale.max = y_max
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,15 @@

<v-row v-if="stretch_function_sync.in_subscribed_states">
<!-- z-index to ensure on top of the jupyter widget with negative margin-top -->
<v-text-field
ref="stretch_hist_nbins"
type="number"
label="Bin Size"
javerbukh marked this conversation as resolved.
Show resolved Hide resolved
v-model.number="stretch_hist_nbins"
hint="The amount of bins used in the histogram."
persistent-hint
:rules="[() => stretch_hist_nbins > 0 || 'Bin size must be greater than zero']"
javerbukh marked this conversation as resolved.
Show resolved Hide resolved
></v-text-field>
<v-switch
v-model="stretch_hist_zoom_limits"
class="hide-input"
Expand Down