From: Michael H. <mh...@al...> - 2012-07-30 09:41:10
|
On 07/26/2012 10:12 AM, Nav wrote: > I want to add a label to the plot with one of the variable coming from > python computation. For example I want the label to be: > > "/Average Number = 44.56/", where 44.56 comes from a computation in the > python code. > > I am trying the following: > > plot.set_label('label sprintf("Average = %f", average) at 1,0.15') > > But I get a message saying "undefined variable average". > > How do I pass a python variable to Gnuplot? > > I would appreciate any help in this regard. Well, this *should* work but it doesn't: plot.set_label('label', 'Average = %f' % average, offset=(1,0.15)) It looks like gnuplot requires "at 1,0.15" for the position rather than "1,0.15" which Gnuplot.py is trying to send. (Maybe this was always broken or maybe gnuplot has changed its syntax in the last 12 years.) So instead, you can use: plot('set label "Average = %f" at 1,0.15' % average) Michael -- Michael Haggerty mh...@al... http://softwareswirl.blogspot.com/ |