I’m encountering an issue with quoted lines in PyGMT while trying to plot lines with labels. Specifically, I want the labels to always appear at the end of the line, so I using the style: “qN+1:+ltext”. However, the problem is that the label is overlapping the line, and I want the label to start right where the line ends. As I increase the font size, the label overlaps the line even more.
I have provided a code example below to illustrate the problem:
import numpy as np
import pygmt
# Generate a two-point line for plotting
x = np.array([2, 4])
y = np.array([5, 5])
fig = pygmt.Figure()
fig.basemap(region=[0, 6, 3, 6], projection="X15c/15c", frame="wsne")
fig.plot(x=x, y=y, pen="2.25p", style="qN+1:+ltext+f15p+p1p")
y -= 1
fig.plot(x=x, y=y, pen="2.25p", style="qN+1:+ltext+f25p+p1p")
fig.show()
The resulting figure shows the label overlapping the line
Is there any way to address this issue? I’ve checked the GMT documentation (plot — GMT 6.4.0 documentation), but couldn’t find a solution. Any help or suggestions would be greatly appreciated. Thank you!
I was expecting a solution like this, but it seems that the nudge modifier (+n) is ignored when using qN+1. It appears that the quoted line will not provide the expected result since I cannot apply an offset to the annotation to remove it from above the plotted line.
No, I want to plot trajectories, and at the end of each trajectory, I want to insert a label with the distance of each trajectory. That’s why it’s important that the label doesn’t overlap with the line, so that the end of the trajectory isn’t covered. I thought there might be a way to add some offset to the label, but the +n (nudge) modifier doesn’t work when -SqN|n+|-1 is used, nor does +jLM. It’s a pity because in this case, the modifiers would be very useful.