Orthogonal Views
A napari plugin for dynamically displaying orthogonal views and syncing events between the different viewers.
A napari plugin for dynamically displaying orthogonal views and syncing events between the different viewers.
This napari plugin was generated with copier using the napari-plugin-template.
This plugin is based on this example, with extra display and synchronization functionalities. The crosshair overlay is based on this and this example.
Installation
You can install the latest development version of napari-orthogonal-views via pip:
pip install git+https://github.com/AnniekStok/napari-orthogonal-views.git
Usage
This plugin is not discoverable as a widget, but commands are available in Views>Commands Palette (CMD+SHIFT+P):
- Show Orthogonal Views
- Hide Orthogonal Views
- Toggle Orthogonal Views
- Remove Orthogonal Views
Once shown, it can also be popped up or collapsed using the checkbox in the bottom right corner 'Show orthogonal views'. Alternatively, you can show the orthogonal views via the console:
from napari_orthogonal_views.ortho_view_manager import show_orthogonal_views
show_orthogonal_views(viewer)
And access the OrthoViewManager via _get_manager:
from napari_orthogonal_views.ortho_view_manager import _get_manager
m = _get_manager(viewer)
m.is_shown()
Out[6]: True
The size of the orthogonal view windows can be adjusted by clicking and dragging the small dot in between the views, optionally one or two views can be hidden entirely. The checkboxes in the bottom right corner can be used to show the crosshair overlay or for more control over camera zoom and axis center syncing.
Pressing T on the keyboard will center all views to the current mouse location.
By default, all events (including label editing such as painting) are synced across all views. The different views share the same underlying data array and undo/redo history.
Syncing properties
By default, all layer properties should be synced between the layer on the main viewer and the orthoviews. However, it is possible to have more finegrained control over the synced properties via the set_sync_filters function, as long as it is specified before the orthogonal views are activated.
For example, to disable syncing of all properties on Tracks layers and specifically the contour property on Labels layers:
from napari_orthogonal_views.ortho_view_manager import _get_manager
from napari.layers import Tracks, Labels
m = _get_manager(viewer)
sync_filters = {
Tracks: {
"forward_exclude": "*", # disable all forward sync
"reverse_exclude": "*", # disable all reverse sync
},
Labels: {
"forward_exclude": "contour" # exclude contour from forward syncing
},
}
m.set_sync_filters(sync_filters)
Then add 3D data (e.g. File > Open Sample > napari builtins > Balls (3D)). Activate the labels layer and change the contour value. You should see that the contour property is not synced from main viewer to orthoviews now.
Layer hooks
Some syncing cannot be expressed as a property copy: painting on a Labels layer, undo/redo, and the point selection each need their own wiring, because they do not emit an event that the property syncing can pick up. These are implemented as layer hooks in layer_sync_hooks.py, and are installed automatically.
A hook is called once per layer, per orthogonal view:
def my_hook(orig_layer, copied_layer):
# do something to the layers, e.g. connect a signal to a handler
orig_layer.events.some_signal.connect(my_handler)
# return a cleanup callable that disconnects the signal again
return [lambda: orig_layer.events.some_signal.disconnect(my_handler)]
Layers can be removed while the orthogonal views stay open, so a hook has to report what it did. It returns an iterable mixing (signal, handler) pairs it connected and zero-argument callables that undo anything else; returning None means it left nothing behind.
Adding behavior
register_layer_hook attaches an extra hook to a layer type. This can be useful if you want the main viewer to respond in a certain way to events of specific layer (sub)classes occuring on the ortho views. For example:
from napari_orthogonal_views.ortho_view_manager import _get_manager
from napari.layers import Labels
m = _get_manager(viewer)
def report_clicks(orig_layer, copied_layer):
def click(layer, event):
orig_layer.selected_label = layer.get_value(
event.position,
view_direction=event.view_direction,
dims_displayed=event.dims_displayed,
world=True,
)
copied_layer.mouse_drag_callbacks.append(click)
return [lambda: copied_layer.mouse_drag_callbacks.remove(click)]
m.register_layer_hook(Labels, report_clicks)
allows the original layer in the main viewer to respond to click events in the ortho views. The property 'selected_label' will then automatically sync to the ortho views as well.
Overriding the built-in behavior
The built-in hooks are keyed by name (layer_tool, labels_undo_redo, labels_paint, points_selection) so a single one can be replaced without disturbing the others. Use this to keep the default behavior and add to it:
from napari_orthogonal_views.layer_sync_hooks import sync_labels_paint
def paint_and_recount(orig_layer, copied_layer):
cleanup = sync_labels_paint(orig_layer, copied_layer)
def on_paint(_event):
my_app.recount_labels(orig_layer)
copied_layer.events.paint.connect(on_paint)
return [*cleanup, (copied_layer.events.paint, on_paint)]
m.set_layer_hook("labels_paint", paint_and_recount)
Passing None disables a built-in entirely. set_layer_hook and register_layer_hook may be called after the orthogonal views are shown; the change then applies to layers added from that point on.
Changing the ortho view layer counterparts
By default, the plugin will create shallow copies of each layer when activating the orthogonal views. These copies are of the same layer type but share the underlying data arrays with the original, to avoid duplication of the data. OrthoViewManager.set_copy_layer allows to change the copy layer function to a custom function: for example, instead of creating a copy of the same layer type, you can specify that the ortho views should make a copy of a specific layer subclass that has slightly different behavior, or that certain layer types should not be copied but produce an empty dummy layer in the ortho views instead.
Screen recording
The 'Screen recording' tab offers a quick way to save a stitched image of the viewer with its orthogonal views. It is also possible to slide along a given axis and record a movie that is saved as a .avi file.
Known issues and ongoing work
- Deprecation warnings on
Window._qt_window,LayerList._get_step_size,LayerList._get_extent_world(suppressed for now). - After removing the OrthoViewManager with
delete_and_cleanup(Remove Orthogonal Views command), the canvas may become temporarily unresponsive. Clicking outside of Napari and then back on the Napari window usually fixes this.
Contributing
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the BSD-3 license, "napari-orthogonal-views" is free and open source software
Issues
If you encounter any problems, please file an issue along with a detailed description.
Version:
- 0.5.0
Last updated:
- 2026-09-11
First released:
- 2025-10-15
License:
- Copyright (c) 2025, Anniek Sto...
Supported data:
- Information not submitted
Plugin type:
Open extension:
Save extension:
Operating system:
- Information not submitted
Requirements:
- napari<0.10,>=0.6.5
- numpy
- qtpy
- superqt
- opencv-python-headless
- napari[all]; extra == "all"
- tox; extra == "testing"
- pytest; extra == "testing"
- pytest-cov; extra == "testing"
- pytest-qt; extra == "testing"
- napari[qt]; extra == "testing"

