Rename napari dimension slider labels

Currently I am viewing 4-d images with napari. These have the dimensions time, x, y, and z.

Napari creates two sliders at the bottom of the UI to scroll through the time and z dimensions. However, these default to being named “0” and “1”. Is there a way to programmatically rename these sliders to be “time” and “z” instead?

Hi yes, there are a couple ways to rename sliders both from the GUI and the API. Definitely something that might need better documentation though.

If you already have a viewer you could do

viewer.dims.axis_labels = ['time', 'z', 'y', 'x']

If you are creating the viewer new you could use the axis_labels keyword argument to Viewer or to view_image. At the end you should see something like this

You can then continue to edit the axis labels by clicking on them in the GUI.

Hope that helps!!

Thank you so much! This is exactly what I needed to know. I agree that it could definitely use some better documentation (:.

1 Like