MATLAB Answers

# Putting Annotation in 3D Space - seems impossible

79 views (last 30 days)
Oliver Ng Kwong Sang on 2 Dec 2020
Answered: Divija Aleti on 8 Dec 2020
Problem: I am trying to put an annotation (An arrow and a text) in a figure that is 3D. But it has been a big struggle so far after trying for 2 days. First the problem with annotation is you have to use normalised units to position the annotation. I found a way around this and was able to use true x and y coordinate values instead to position the annotation.
But now I am trying to put the annotation in 3D space. I can easily put an annotation in 2D space but in 3D space, there is a problem: I cannot add the z-coordinate for it. The Syntax for annotation is like this: a = annotation('textarrow',x,y,'String','Write text here'); where x and y are the normalised unit for the figure. When I try to add z into it, MATLAB gives an error which states the vector ([x y z]) is too big.
Could someone please tell me how to solve this? Or is there another function instead to use in 3D space?
(Note: I tried using text function in 3D space and it works but I would like to use annotation because I can then put an arrow and a text.)
Thank you MATLAB community!
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Divija Aleti on 8 Dec 2020
Hi Oliver,
The annotation function with the same syntax - 'a= annotation('textarrow',x,y,'String','Write text here');' can be used for 3D space too. It shows the annotation on the figure, but the z-position cannot be specified.
However, in order to put an arrow in a particular position in 3D space, that is, specify x,y and z positions, you can use the 'arrow' function. This can be downloaded from the link below:
After putting the arrow, you can use the 'text' function to display your text:
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!