Show axes (reference) in the 3D canvas

Hi again!

In this opportunity I have some basics and little questions about the usage of napari :slight_smile:

  1. Is possible to show ·3D axes on the canvas? At the moment, I solved this issue making a vector layer like this:
viewer = napari.Viewer(ndisplay=3)

n_axes = 3
vectors = np.zeros((n_axes, 2, 3), dtype=np.float32)
x_px = np.array([1, 0, 0])
y_py = np.array([0, 1, 0])
z_pz = np.array([0, 0, 1])
vectors[0, 1] = x_px
vectors[1, 1] = y_py
vectors[2, 1] = z_pz
viewer.add_vectors(vectors, name='Axes', edge_width=3, length=50)
viewer.add_points(np.zeros(3), name='Reference', size=10)

But, I think maybe there is a more straightforward method to do it

  1. Related to the previous question, is it possible to put text to the vectors? (for example ‘X’ ‘Y’ ‘Z’). I know I can do it with extra points layer (point layer has ‘text’ parameter), but I want to know again if there is a straightforward mechanism.

Thanks!

2 Likes

We actually don’t have this functionality easily exposed, but agreed there should be something at the canvas level to turn this on/ off. It’s come up recently as we work on adding affine transforms. I’ve created a dedicate issue for this feature here https://github.com/napari/napari/issues/1687. Depending on how things go we might be able to get it in for our upcoming 0.4.0 release!

2 Likes

Thanks! I hope that! Good job napari team!

Yeah we should have this already (thanks @sofroniewn for making the issue) but I love the workaround @scaracciolo! Thanks for sharing!

1 Like

Turns out there already was an issue, I just forgot!! https://github.com/napari/napari/issues/952

1 Like

@scaracciolo we’re making some good progress on adding the reference axes visual - feel free to check things out on the PR linked below and weigh in with any feedback, we should have it merged fairly soon! https://github.com/napari/napari/pull/1719

2 Likes

This functionality has now been merged into napari and will be in the next release, see

We’ve also go an issue to discuss further enhancements here https://github.com/napari/napari/issues/1726

Thanks all!!

2 Likes