0

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.

2
  • Why not just add two text labels with ax.text()? Commented Jan 14, 2015 at 22:20
  • @OliverW., I tried ax1.text(.6, .06, r'Hello'). It doesn't work. And ax1.annotate('text', xytext=(.6, .06)) also Commented Jan 14, 2015 at 23:00

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.