cphyc / matplotlib-label-lines

Label line using matplotlib.
MIT License
301 stars 28 forks source link

Making the text transparent #93

Closed abcnishant007 closed 2 years ago

abcnishant007 commented 2 years ago

Is there a way to increase the transparency of the on-line text label. Currently, it is fully opaque.

P.S congrats on the awesome package!

cphyc commented 2 years ago

Yes, any extra argument passed to labelLines[s] will be passed down to a matplotlib plt.text(…) call. So you for example do something like

from labellines import labelLines
import numpy as np

x = np.linspace(0, 2*np.pi, 100)
y = np.cos(x)
line, = plt.plot(x, y, label="cos x")
labelLines(line, alpha=0.5)

image This is not perfect because the outline is transparent as well, but that's a good start!

abcnishant007 commented 2 years ago

Got it, thanks! Please feel free to close the issue