Re: [Matplotlib-users] [matplotlib-users] Using variables in annotations

2009-12-31 Thread Johan Grönqvist
Manuel Wittchen skrev:
> Is it possible to print the value of a variable in an annotation?
> Example:
> 
> gradient = 2.0
> intercept = 3.0
> r-value = 0.99
> 
> ax.annotate('f(x) = gradient * x + intercept R^2 = r-value',
> xy=(2.9,-0.75), xytext=(2.9,-0.75))
> 

I feel that a main advantage of matplotlib (over other solutions I have 
used) is that there is a complete programming language available. In 
this case, just use the standard string handling of python.

See e.g. http://docs.python.org/library/stdtypes.html#string-formatting

Untested code:

annotation_string = "f(x) = %f * x + %f R^2 = %f" % (gradient, 
intercept, r-value)

ax.annotate(annotation_string,
xy=(2.9,-0.75), xytext=(2.9,-0.75))




/ johan


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem generating postscript

2009-12-31 Thread Jouni K . Seppänen
Eric Emsellem  writes:

> regarding my last post, I still have pb generating simple eps files.

Can you be more specific about the "last post" you are referring to? I
searched using Gmane and didn't find anything recent:

http://search.gmane.org/?author=eric+emsellem&group=gmane.comp.python.matplotlib.general&sort=date

> thanks a lot for the quick tip. But no xpdf does not do it (I had
> tried it).

What exact error message do you get in that case?

> ps.usedistiller   : None
> ## I tried all possible distiller... didn't change the pb.

Certainly the error message must have changed between runs, since your
first post showed a Ghostscript-specific message.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] [matplotlib-users] Using variables in annotations

2009-12-31 Thread Manuel Wittchen
Hi,

Is it possible to print the value of a variable in an annotation?
Example:

gradient = 2.0
intercept = 3.0
r-value = 0.99

ax.annotate('f(x) = gradient * x + intercept R^2 = r-value',
xy=(2.9,-0.75), xytext=(2.9,-0.75))

Where gradient, intercept and r-value should be replaced by the value
of the variables in the output.

Regards and a happy new year!
Manuel Wittchen

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users