Search code examples
matlabannotations

annotation() and text() in Matlab


I wonder what is the difference between annotation() and text() functions in Matlab? In what cases are one of them preferred over the other?


Solution

  • TEXT positions text in relation to axes. In contrast, ANNOTATION position is figure-related. ANNOTATION can put on figure not only text, but lines, shapes, arrows, etc. Consequently, TEXT takes axes handles as an argument (or gca for current axes), and ANNOTATION takes figure handles (or gcf for current figure).