Skip to content

Only tick slice xticks at integer values #174

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 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Changes
- ``NapariMPLWidget.update_layers()`` has been removed as it is intended to be
private API. Use ``NapariMPLWidget.on_update_layers`` instead to implement
funcitonality when layer selection is changed.
- The slice widget now only plots x-ticks at integer locations.

Bug fixes
~~~~~~~~~
Expand Down
5 changes: 5 additions & 0 deletions src/napari_matplotlib/slice.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Any, Dict, Optional, Tuple

import matplotlib.ticker as mticker
import napari
import numpy as np
import numpy.typing as npt
Expand Down Expand Up @@ -116,3 +117,7 @@ def draw(self) -> None:
self.axes.plot(x, y)
self.axes.set_xlabel(self.current_dim)
self.axes.set_title(self._layer.name)
# Make sure all ticks lie on integer values
self.axes.xaxis.set_major_locator(
mticker.MaxNLocator(steps=[1, 2, 5, 10], integer=True)
)
Binary file modified src/napari_matplotlib/tests/baseline/test_slice_2D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.