# How can I draw curved text on a curved line so that the text follows the line?

31 views (last 30 days)
MathWorks Support Team on 6 Oct 2020
Answered: Zaid hamamah on 7 Apr 2022
I have a curved line that I want to plot text on. I wanted the text to follow the curve on the line. How can I do this?

### Accepted Answer

MathWorks Support Team on 6 Oct 2020
Currently, there is no built-in option to have text follow the curvature of a line it is plotted on.
One current workaround to this is to plot each letter on the line while rotating the letter to match the curve of the line at the point. To do this:
1. Take the length of the string you wish to plot ('m') and separate your curve into m+1 points that are equidistant from each other.
2. Find the slope between the two points and use 'atan' to calculate the degrees or radians of the slope.
3. Use the 'rotation' property of 'text' to set the rotation of the letter to the desired rotation of the curve. Plot each letter to each equidistant point on the desired curve.
For more information regarding 'text', please refer to the link below:
##### 0 CommentsShow -1 older commentsHide -1 older comments

Sign in to comment.

### More Answers (1)

Zaid hamamah on 7 Apr 2022
Hi, it might be too late to answer the question but just for the future readers:
try this code:
It has an option where you can add 'slope' at the end of the command syntax to get the text in line with the local slope. You can also choose where to put the text.
##### 0 CommentsShow -1 older commentsHide -1 older comments

Sign in to comment.

### Categories

Find more on Annotations in Help Center and File Exchange

R2019b

### Community Treasure Hunt

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

Start Hunting!