Skip to content
Merged
Changes from 3 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
9 changes: 8 additions & 1 deletion src/napari_matplotlib/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ def draw(self) -> None:
Clear the axes and histogram the currently selected layer/slice.
"""
layer = self.layers[0]
bins = np.linspace(np.min(layer.data), np.max(layer.data), 100)
print(layer.data.shape)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug output? To be removed?


if layer.data.ndim - layer.rgb == 3:
# 3D data, can be single channel or RGB
data = layer.data[self.current_z]
self.axes.set_title(f"z={self.current_z}")
else:
data = layer.data
# Read data into memory if it's a dask array
data = np.asarray(data)

# Important to calculate bins after slicing 3D data, to avoid reading
# whole cube into memory.
bins = np.linspace(np.min(data), np.max(data), 100)
print(bins)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(bins)

Ditto.


if layer.rgb:
# Histogram RGB channels independently
Expand Down