self.line.set_color(self.get_color())
plt.gca().add_artist(self.line)
plt.gca().add_artist(self)
if __name__ == '__main__':
    x = np.linspace(0, 1, 20)
y = np.linspace(0, 1, 20)
ax = plt.subplot(1, 1, 1)
line = plt.plot(x, y, 'r--', alpha=0.5)[0]
linetext = LineText(line, text='abc')
plt.show(block=False)
Subclassing matplotlib Text: manipulate properties of child artist