David Porter wrote:
>Mike
> I have a few Python/Gnuplot questions that I hope you may have an answer to.
>
I'm sending a copy of this response to the gnuplot-py-users mailing
list. Please consider subscribing and sending future questions to the list.
>1. How do you have a multi-line title? I have tried g.title("line1\nline2\nline3") and only line1 shows up on the plot. I have debug=1 and what I see is:
>gnuplot> set title "line1
>line2"
>what I think it should be is:
>gnuplot> set title "line1\nline2"
>
Then an immediate solution would be to type
>>> g.title("line1\\nline2\\nline3")
or
>>> g.title(r"line1\nline2\nline3")
Perhaps Gnuplot.py should quote newlines automatically? If so, what
other characters should it quote?
>2. Adding labels, I have been able to add a label with the following:
>g('set label "Label text" at 0, floating point value') where floating point value is a real number on the y axis. What happens if "Label text is a string and floating point value is a variable:
>label_test = "Label Text"
>y1 = floating point value
>g('set label label_text, 0, y1')
>I guess the real question is how to tell gnuplot-py label_text is a string and y1 is a floating point value?
>
>
You just need to use Python's "%" string operator:
>>> g('set label "%s", 0, %g' % (label_test, y1,))
See the python tutorial or the python library reference (the section
called "String Formatting Operations") at www.python.org for more
information.
Michael
--
Michael Haggerty
mh...@al...
|