Skip to content

Use integer bins for integer data in HistogramWidget #244

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

Merged
merged 9 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Ensure step size is at least 1
Update baseline images
  • Loading branch information
p-j-smith committed Jan 15, 2024
commit 610f19cbeae553c969785763f3d505e46847771d
3 changes: 2 additions & 1 deletion src/napari_matplotlib/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def draw(self) -> None:
# whole cube into memory.
if data.dtype.kind in {"i", "u"}:
# Make sure integer data types have integer sized bins
step = 1 + abs(np.max(data) - np.min(data)) // 100
step = abs(np.max(data) - np.min(data)) // 100
step = max(1, step)
bins = np.arange(np.min(data), np.max(data) + step, step)
else:
bins = np.linspace(np.min(data), np.max(data), 100)
Expand Down
Binary file modified src/napari_matplotlib/tests/baseline/test_histogram_2D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/napari_matplotlib/tests/baseline/test_histogram_3D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.