Skip to content

Commit 5e983b2

Browse files
committed
vispy histogram: Remove log cruft
1 parent 7c75db8 commit 5e983b2

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/ndv/views/_vispy/_histogram.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __init__(self, *, vertical: bool = False) -> None:
9999

100100
## -- Plot -- ##
101101
self.plot = PlotWidget()
102-
self.plot.lock_axis("y")
102+
# self.plot.lock_axis("y")
103103
self._canvas.central_widget.add_widget(self.plot)
104104
self.node_tform = self.plot.node_transform(self.plot._view.scene)
105105

@@ -137,13 +137,13 @@ def set_gamma(self, gamma: float) -> None:
137137
if gamma < 0:
138138
raise ValueError("gamma must be non-negative!")
139139
self._gamma = gamma
140-
self._update_lut_lines()
140+
self._update_lut_ctrls()
141141

142142
def set_clims(self, clims: tuple[float, float]) -> None:
143143
if clims[1] < clims[0]:
144144
clims = (clims[1], clims[0])
145145
self._clims = clims
146-
self._update_lut_lines()
146+
self._update_lut_ctrls()
147147

148148
def set_clim_policy(self, policy: ClimPolicy) -> None:
149149
# Nothing to do (yet)
@@ -192,23 +192,19 @@ def set_vertical(self, vertical: bool) -> None:
192192
self.plot.lock_axis("x" if vertical else "y")
193193
# When vertical, smaller values should appear at the top of the canvas
194194
self.plot.camera.flip = [False, vertical, False]
195-
self._update_lut_lines()
195+
self._update_lut_ctrls()
196196
self._resize()
197197

198198
def set_log_base(self, base: float | None) -> None:
199199
if base != self._log_base:
200-
if self._log_base is not None and self._range:
201-
self._range = tuple(self._log_base**x for x in self._range)
202-
self._log_base = None if base is None else 2**base
203-
if self._log_base is not None and self._range:
204-
self._range = tuple(
205-
np.log(x) / np.log(self._log_base) for x in self._range
206-
)
200+
self._log_base = base
201+
# Update histogram
207202
self._update_histogram()
208-
self._update_lut_lines()
203+
# Resize vertical axis
209204
camera_rect = self.plot.camera.rect
210205
self._resize(x=(camera_rect.left, camera_rect.right))
211-
# HACK: Disable labels for log axis - there has to be a better way
206+
207+
# Disable labels for log axis
212208
self.plot.yaxis.axis.tick_color = (
213209
(0, 0, 0, 0) if base is not None else (1, 1, 1, 1)
214210
)
@@ -252,7 +248,12 @@ def _update_histogram(self) -> None:
252248
# Looks like https://github.com/vispy/vispy/issues/1899
253249
self._hist_mesh._bounds_changed()
254250

255-
def _update_lut_lines(self, npoints: int = 256) -> None:
251+
def _update_lut_ctrls(self, npoints: int = 256) -> None:
252+
"""
253+
Updates the DOMAIN of the lut controls.
254+
255+
Note that the RANGE is automatically scaled in _resize()
256+
"""
256257
if self._clims is None or self._gamma is None:
257258
return # pragma: no cover
258259

0 commit comments

Comments
 (0)