annotation problem

I meant to be copying an annotation example from
http://matplotlib.sourceforge.net/examples/annotation_demo.bak.py
but it is not working. Am I just too bleary eyed because it
is later here, or is there a problem with the example?

Thank you,
Alan Isaac

%%%%%%%%%%%% Illustrate Annotation Problem %%%%%%%%%%%%%%%%%%%%%
import pylab
import matplotlib as mpl
test = pylab.figure()
test_ax = test.gca()
test_ax.plot([1,2,3])

#the following line fails with "ValueError: too many values to unpack"
a = mpl.text.Annotation(
test,
'F: a figure title (points)',
loc=(-10, -10),
coords='figure points',
horizontalalignment='right',
verticalalignment='top',
fontsize=20)

test_ax.add_artist(f)
test.savefig(r'c:\temp\temp.eps')

Alan G Isaac wrote:

I meant to be copying an annotation example from
http://matplotlib.sourceforge.net/examples/annotation_demo.bak.py

I don't see much resemblance to that example; and I haven't tried that example, but I did verify that the examples/annotation_demo.py in svn works as expected.

but it is not working. Am I just too bleary eyed because it is later here, or is there a problem with the example?

Time for bed, rest those bleary eyes...

The signature of the Annotation.__init__ does not match what you were trying to feed it. Here is a modification that does match, but that may not be anything like what you were trying to do:

import pylab
import matplotlib as mpl
test = pylab.figure()
test_ax = test.gca()
test_ax.plot([1,2,3])

a = mpl.text.Annotation(

'F: a figure title (points)',
(-10, -10),
xycoords='figure points',
horizontalalignment='right',
verticalalignment='top',
fontsize=20)

test_ax.add_artist(a)
test.savefig('temp.eps')

···

------------------
Eric

Thank you,
Alan Isaac

%%%%%%%%%%%% Illustrate Annotation Problem %%%%%%%%%%%%%%%%%%%%%
import pylab
import matplotlib as mpl
test = pylab.figure()
test_ax = test.gca()
test_ax.plot([1,2,3])

#the following line fails with "ValueError: too many values to unpack" a = mpl.text.Annotation(
test,
'F: a figure title (points)',
loc=(-10, -10),
coords='figure points',
horizontalalignment='right',
verticalalignment='top',
fontsize=20)

test_ax.add_artist(f)
test.savefig(r'c:\temp\temp.eps')

Alan G Isaac wrote:

I meant to be copying an annotation example from
http://matplotlib.sourceforge.net/examples/annotation_demo.bak.py

The signature of the Annotation.__init__ does not match what you were
trying to feed it.

OK, I can see that at
http://matplotlib.sourceforge.net/matplotlib.text.html
So then the examples *are* wrong at
http://matplotlib.sourceforge.net/examples/annotation_demo.bak.py
Right?

Your example is sending me down the right track.
But I am still getting an odd result with

a = mpl.text.Annotation('text', (0.5,0.5), xycoords="axes fraction", fontsize=20)
fig_ax.add_artist(a)

Shouldn't this put the text smack in the middle of the figure?

OK, I give up for now. Time for some sleep.

Thanks!
Alan

···

On Fri, 31 Aug 2007, Eric Firing apparently wrote: