SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Manuel W. <man...@gm...> - 2009年12月31日 09:56:29
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
From: Johan G. <joh...@gm...> - 2009年12月31日 13:22:01
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
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /