1

I am writing a calculator type thing in python. I am attempting to label the x intercepts in a plot, but the text keeps overlapping with the line and the other text, due to there being no "good" position to put the text as the values of the intercepts range by a lot.

is there any good way to annotate and force the text not to overlap?

here is the code piece in question:

plt.annotate('x intercept 1 (' + str(x1) + ',0)', xy=(x1, 0), xytext=(x1+3, 0.5),
                arrowprops=dict(facecolor='black', shrink=0.05),
            )
plt.annotate('x intercept 2 (' + str(x2) + ',0)', xy=(x2, 0), xytext=(x2-3, 10),
                arrowprops=dict(facecolor='black', shrink=0.05),
            )
Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188

0 Answers0