# Rotate text such that it aligns with the gradient of a line

Hello, I’m trying to make some text line up with a line from A to B, the problem is that the angle is fixed and not relative to the aspect ratio of the figure. I suppose a way to do it is to get the size of the figure and adjust, but I’m not sure how to do that either. Any help is appreciated.

Here’s a MWE to demonstrate my problem:

``````using Plots

points = [[0.1, 0.3], [0.3, 0.5]]
midpoint = ((points[1][2] - points[1][1], points[2][2] - points[2][1]) ./ 2) .+ (points[1][1], points[2][1])
p = Plots.plot(xlims = (0,1), ylims = (0,1))
Plots.plot!(points...)
Plots.annotate!(p, midpoint[1], midpoint[2] + 0.1, Plots.text("30", 10, :dark, rotation = 30))
Plots.plot!(size = (500, 500))
``````

You mean, like this?

1 Like

Yes but for a straight line. Although that is very pretty.

Well, for straight lines is even simpler. Same principle but simpler because no need to generate the spiral. Just two points are needed.

Anything using the GR backend for Plots? I’m not sure if you can mix and match, and I’ve done anything else using GR.