UserOnWeb
UserOnWeb

Reputation: 98

Matplotlib add text such that it will end at point

I want to annotate text on the matplotlib plot where my text should end at given point. For example,

fig, ax = plt.subplots()
ax.text(1,1,"my text")

In above example "my text" will start at point (1,1). How can I make it to end at (1,1)?

I can always play around with points and manually adjust it, however, I want to do it automatically.

Upvotes: 3

Views: 607

Answers (1)

Dexter
Dexter

Reputation: 1531

You can do following,

ax.text(1,1,"my text", ha="right")

Which essentially defines the text alignment. More details can be found here.

Upvotes: 1

Related Questions