matplotlib-label-lines icon indicating copy to clipboard operation
matplotlib-label-lines copied to clipboard

Add xoffsets kwarg

Open scottshambaugh opened this issue 8 months ago • 1 comments

Closes https://github.com/cphyc/matplotlib-label-lines/issues/176 by adding xoffsets as a kwarg, similar to yoffsets. Properly handles both numeric and timedelta offsets.

scottshambaugh avatar Mar 07 '25 16:03 scottshambaugh

This lets me get a plot like I was wanting in the original issue!

import matplotlib.pyplot as plt
import numpy as np
from labellines import labelLines

pi_2 = np.pi/2
x = np.linspace(0, pi_2, 100)
fig, ax = plt.subplots()

for i in range(3):
    ax.plot(x, np.sin(x) + i, label=f'x{i}')
labelLines(ax.get_lines(), zorder=2.5, xvals=(pi_2 - 1e-12), xoffsets=0.1)
ax.set_xlim(0, pi_2 + 0.2)

test

scottshambaugh avatar Mar 07 '25 16:03 scottshambaugh