0
votes

I have a plot and want a legend placed in the upper right corner without any frame around with two lines:

a = 10
b = 3*pi

Those lines are some coefficients of my plotted function.

So far, I have

ax1.plot(x, y, label='a')
ax1.legend(["a = 10", "b = 3*pi"], loc="upper right", ncol=1, frameon=False)

But that keeps lines type or color next to my two strings. How to remove them? Put it in the title is not an option. There is a different text.

1
Why not just add two text labels with ax.text()? - Oliver W.
@OliverW., I tried ax1.text(.6, .06, r'Hello'). It doesn't work. And ax1.annotate('text', xytext=(.6, .06)) also - Olga

1 Answers

1
votes

Use the text method of the axes object. Also, remember that the default is that the first 2 arguments of ax1.text are in data coordinates, so in your example, Hello will be put at (x,y)=(.6, .06), unless you also add the parameter transform=ax1.transAxes to ax1.text, like so:

ax1.text(.60, .06, r'Hello', transform=ax1.transAxes)

That will add the text label a little over halfway from the left and a little higher than the bottom of the axes.