Skip to content

Commit 845de27

Browse files
committed
Only tick slice xticks at integer values
1 parent 749809e commit 845de27

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Changes
2828
- ``NapariMPLWidget.update_layers()`` has been removed as it is intended to be
2929
private API. Use ``NapariMPLWidget.on_update_layers`` instead to implement
3030
funcitonality when layer selection is changed.
31+
- The slice widget now only plots x-ticks at integer locations.
3132

3233
Bug fixes
3334
~~~~~~~~~

src/napari_matplotlib/slice.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Any, Dict, Optional, Tuple
22

3+
import matplotlib.ticker as mticker
34
import napari
45
import numpy as np
56
import numpy.typing as npt
@@ -116,3 +117,7 @@ def draw(self) -> None:
116117
self.axes.plot(x, y)
117118
self.axes.set_xlabel(self.current_dim)
118119
self.axes.set_title(self._layer.name)
120+
# Make sure all ticks lie on integer values
121+
self.axes.xaxis.set_major_locator(
122+
mticker.MaxNLocator(steps=[1, 2, 5, 10], integer=True)
123+
)
Loading

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy