|
From: fusselpelusa <jun...@gm...> - 2006-08-07 06:42:00
|
Hi, I have a problem with labelling my plots at an arbitrary position (set label "... %f" '???filename and column/line???' at ....) using values from a file. Searching in the gnuplot manual did not help unfortunately. A google-search did not do the job either. Perhaps I have to use the awk(?) or sed (?) command? Anyway, as the value I would like to be as label is not the only one in the line of my data file, perhaps awk will not work? Right now, my data file consists of two columns, from where I am plotting all except the last line (with the every command). The interesting number in the last line is the one in the second column which should be the label of the graph. I am pretty new to the unix/gnuplot area. That's why the online helping tools/manuals for awk/sed ... are a bit too short for me to understand without lots of examples. Additionally I would like to implement underneith the plot a few lines of text from another textfile like a caption, is this possible with gnuplot? Thanks a lot for your help and sorry if I am posting an already answered question, I could not find any related answer while searching in the forums archive. Cheers Fusselpelusa -- View this message in context: http://www.nabble.com/Label-value-from-file-and-caption-under-the-graph-tf2061910.html#a5680184 Sent from the Gnuplot - User forum at Nabble.com. |
|
From: Tammo H. <Tam...@ie...> - 2006-08-07 11:17:02
|
> Hi, > I have a problem with labelling my plots at an arbitrary position (set label > "... %f" '???filename and column/line???' at ....) using values from a file. I don't think that this is possible. You might be able to somehow do it with variables that you set to contain your text. But I don't know how you would set those variables. I don't think you can set variables using a datafile (like the plot command). Would be nice though. You could have an external program write a file 'setvariables.gp' containing: set <variable> = <text> and execute 'setvariables.gp' in your script, like: load setvariables.gp Then you could use <variable> in your label command instead of the text. That might work. > Searching in the gnuplot manual did not help unfortunately. A google-search > did not do the job either. Perhaps I have to use the awk(?) or sed (?) > command? Anyway, as the value I would like to be as label is not the only > one in the line of my data file, perhaps awk will not work? > Right now, my data file consists of two columns, from where I am plotting > all except the last line (with the every command). The interesting number in > the last line is the one in the second column which should be the label of > the graph. > I am pretty new to the unix/gnuplot area. > That's why the online helping tools/manuals for awk/sed ... are a bit too > short for me to understand without lots of examples. > > Additionally I would like to implement underneith the plot a few lines of > text from another textfile like a caption, is this possible with gnuplot? > Thanks a lot for your help and sorry if I am posting an already answered > question, I could not find any related answer while searching in the forums > archive. > Cheers > Fusselpelusa -- Tammo Heeren, Ph.D mailto: Tam...@ie... |
|
From: <br...@ph...> - 2006-08-07 19:37:00
|
fusselpelusa wrote:
> Hi,
> I have a problem with labelling my plots at an arbitrary position (set label
> "... %f" '???filename and column/line???' at ....) using values from a file.
That's not surprising --- you can't do that. Gnuplot reads data from
outside files only in the {re|s|}plot commands. If you want to extract
a single piece of data from a file, you have to do that outside gnuplot,
and feed the result back into it as a command. The version-4.0 trick of
'set label "foo = %f", foo' works only for gnuplot-internal, numeric
variables, not for arbitrary data from external files.
If you want to extract lots of data from a file, wait for the 4.2
release and then use 'plot "file" with labels'
> Anyway, as the value I would like to be as label is not the only
> one in the line of my data file, perhaps awk will not work?
It will. You're badly underestimating awk. someone once wrote an
entire multi-targeting macro assembler in awk.
> Additionally I would like to implement underneith the plot a few lines of
> text from another textfile like a caption, is this possible with gnuplot?
Possible, sure (generate a multi-line 'set ylabel' or several 'set
label' commands from it), but rarely advisable. If you want a caption,
do it outside gnuplot, in the document processing system you're putting
that plot in.
|
|
From: Thomas S. <t.s...@fz...> - 2009-04-24 12:57:57
|
with version >=4.2 a textstring can be read from a file using commands your operating system provides, have a look at the 1st and 2nd example in: http://gnuplot.sourceforge.net/demo/stringvar.html Alice5785 wrote: > > Hi! > I searched for a possibilty to plot textstrings from a file (e.g. the > slope out of fit.log) in gnuplot as a label and so I got this answer to a > similar problem > Did I get it right, that there is no way to "call" a text string from a > file and put it in a gnuplot-label? > > > > Tammo Heeren-2 wrote: >> >>> Hi, >>> I have a problem with labelling my plots at an arbitrary position (set >>> label >>> "... %f" '???filename and column/line???' at ....) using values from a >>> file. >> >> I don't think that this is possible. >> You might be able to somehow do it with variables that you set to contain >> your text. But I >> don't know how you would set those variables. I don't think you can set >> variables using a >> datafile (like the plot command). Would be nice though. You could have an >> external >> program write a file 'setvariables.gp' containing: >> >> set <variable> = <text> >> >> and execute 'setvariables.gp' in your script, like: >> >> load setvariables.gp >> >> Then you could use <variable> in your label command instead of the text. >> That might work. >> >>> Searching in the gnuplot manual did not help unfortunately. A >>> google-search >>> did not do the job either. Perhaps I have to use the awk(?) or sed (?) >>> command? Anyway, as the value I would like to be as label is not the >>> only >>> one in the line of my data file, perhaps awk will not work? >>> Right now, my data file consists of two columns, from where I am >>> plotting >>> all except the last line (with the every command). The interesting >>> number in >>> the last line is the one in the second column which should be the label >>> of >>> the graph. >>> I am pretty new to the unix/gnuplot area. >>> That's why the online helping tools/manuals for awk/sed ... are a bit >>> too >>> short for me to understand without lots of examples. >>> >>> Additionally I would like to implement underneith the plot a few lines >>> of >>> text from another textfile like a caption, is this possible with >>> gnuplot? >>> Thanks a lot for your help and sorry if I am posting an already answered >>> question, I could not find any related answer while searching in the >>> forums >>> archive. >>> Cheers >>> Fusselpelusa >> >> >> >> >> -- >> Tammo Heeren, Ph.D >> mailto: Tam...@ie... >> >> >> ------------------------------------------------------------------------- >> Take Surveys. Earn Cash. Influence the Future of IT >> Join SourceForge.net's Techsay panel and you'll get the chance to share >> your >> opinions on IT & business topics through brief surveys -- and earn cash >> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >> _______________________________________________ >> Gnuplot-info mailing list >> Gnu...@li... >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> >> > > -- View this message in context: http://www.nabble.com/Label-value-from-file-and-caption-under-the-graph-tp5680184p23215950.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
|
From: Alice5785 <Al...@st...> - 2009-04-26 08:30:06
|
Thanks a lot! I think I finally got it :)
That was my label first:
set label 2 "F = 98847.8 C/mol +/- 1.052e+04 C/mol (10.64%)" at 9.5,700000
now it's a little bit longer :)
set label 1 "Faradaykonstante aus Steigung der Geraden" at 9.5,800000
set label 2 "F = " at 9.5,700000
set label 3 sprintf("%f",a) at 10.5,700000
set label 4 "C/mol +/- " at 15.1,700000
set label 5 sprintf("%f",a_err) at 18,700000
the only thing I have problems with are the digits after the comma (I just
wanted to show maybe two digits) and how I can show the percental value. Do
you have some advice for me?
Alice
--
View this message in context: http://www.nabble.com/Label-value-from-file-and-caption-under-the-graph-tp5680184p23240238.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|
|
From: Dr. I. D. J. <die...@t-...> - 2009-04-26 09:23:24
|
Hi Alice,
two hints for you:
1.) do not place the labels with
set label 1 "Faradaykonstante aus Steigung der Geraden" at 9.5,7.0
I would recommed you to do it like
set label 1 "Faradaykonstante aus Steigung der Geraden" at graph 0.7,0.4
where "0.7" is equal to 9.5/xrange (your current x-axes value for the label).
The value "0.7" is therefors surely wrong as I do not know your current xrange
setting. The same needs to be done for the yrange, i.e. "0.4" in my example
should be calculated as "7.0/yrange".
The reason for this is simple: given you have to modify the xrange, yrange
settings, the placement of your labels in the graph will remain constant. You
do not have to modify those settings every other time you change ranges.
2.) for the digits behind the comma you need to use the sprintf syntax:
set label 3 sprintf("%4.1",a) at graph 0.8,0.6
will give you 4 digits in total and one behind the comma - adapt this to what
you actually need.
Hope this helps,
take care
Dieter Jurzitza
Am Sonntag 26 April 2009 10:30:03 schrieb Alice5785:
> Thanks a lot! I think I finally got it :)
>
> That was my label first:
******
--
-----------------------------------------------------------
|
\
/\_/\ |
| ~x~ |/-----\ /
\ /- \_/
^^__ _ / _ ____ /
<°°__ \- \_/ | |/ | |
|| || _| _| _| _|
if you really want to see the pictures above - use some font
with constant spacing like courier! :-)
-----------------------------------------------------------
|
|
From: Alice5785 <Al...@st...> - 2009-04-26 11:34:57
|
Thank you very much!
I have now what I wanted, looks a little difficult but it wirks :-)
for those who want to know how (but you will need a file.dat file with the
columns "volumina in ml", "time in sec", "meausred height in cm"):
f(x)=a*x+b
set fit errorvariables
fit f(x) "file.dat" using
($1*(0.99458e5+1.08e3*9.81*$3*1e-2-0.94*3.08e3)*273.15/(1.01325e5*297.66)):(4.4828e3*$2)
via a,b
set label 1 "Faraday-constant from slope of the fit" at graph 0.38,0.4
set label 2 "F = [ " at graph 0.38,0.35
set label 3 sprintf("%.2f +/- %.2f (%.2f%%)",a,a_err,a_err/a*100) at graph
0.44,0.35
set label 4 "] C/mol" at graph 0.84,0.35
set label 5 "from that: Avogadro-constant:" at graph 0.38,0.28
set label 6 "N_A = " at graph 0.38,0.22
set label 7 sprintf("%.5e",a/1.602176487e-19) at graph 0.47,0.22
set label 8 "particles/mol" at graph 0.65,0.22
important: without the "set fit errorvariables" you won't have the
"_err"-Variables!
--
View this message in context: http://www.nabble.com/Label-value-from-file-and-caption-under-the-graph-tp5680184p23241376.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|
|
From: Thomas S. <t.s...@fz...> - 2009-04-26 16:23:37
|
you may save some time (used for positioning the contents of one
line) by writing the surrounding text into the sprintf command:
set label 1 sprintf("F = [ %.2f +/- %.2f (%.2f%%) ]
C/mol",a,a_err,a_err/a*100) at graph 0.38,0.35
set label 6 sprintf("N_A = %.5e particles/mol",a/1.602176487e-19) at graph
0.38,0.22
this has the advantage of being font size independant.
Alice5785 wrote:
>
> Thank you very much!
> I have now what I wanted, looks a little difficult but it wirks :-)
>
> for those who want to know how (but you will need a file.dat file with the
> columns "volumina in ml", "time in sec", "meausred height in cm"):
>
> f(x)=a*x+b
> set fit errorvariables
> fit f(x) "file.dat" using
> ($1*(0.99458e5+1.08e3*9.81*$3*1e-2-0.94*3.08e3)*273.15/(1.01325e5*297.66)):(4.4828e3*$2)
> via a,b
>
> set label 1 "Faraday-constant from slope of the fit" at graph 0.38,0.4
> set label 2 "F = [ " at graph 0.38,0.35
> set label 3 sprintf("%.2f +/- %.2f (%.2f%%)",a,a_err,a_err/a*100) at graph
> 0.44,0.35
> set label 4 "] C/mol" at graph 0.84,0.35
> set label 5 "from that: Avogadro-constant:" at graph 0.38,0.28
> set label 6 "N_A = " at graph 0.38,0.22
> set label 7 sprintf("%.5e",a/1.602176487e-19) at graph 0.47,0.22
> set label 8 "particles/mol" at graph 0.65,0.22
>
>
> important: without the "set fit errorvariables" you won't have the
> "_err"-Variables!
>
--
View this message in context: http://www.nabble.com/Label-value-from-file-and-caption-under-the-graph-tp5680184p23243755.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|
|
From: Alice5785 <Al...@st...> - 2009-04-26 17:13:12
|
oh very nice, thanks again :) those things I write into a tex-file, so that I
don't have to search every time I need it :)
Thomas Sefzick wrote:
>
> you may save some time (used for positioning the contents of one
> line) by writing the surrounding text into the sprintf command:
>
> set label 1 sprintf("F = [ %.2f +/- %.2f (%.2f%%) ]
> C/mol",a,a_err,a_err/a*100) at graph 0.38,0.35
>
> set label 6 sprintf("N_A = %.5e particles/mol",a/1.602176487e-19) at graph
> 0.38,0.22
>
> this has the advantage of being font size independant.
>
>
> Alice5785 wrote:
>>
>> Thank you very much!
>> I have now what I wanted, looks a little difficult but it wirks :-)
>>
>> for those who want to know how (but you will need a file.dat file with
>> the columns "volumina in ml", "time in sec", "meausred height in cm"):
>>
>> f(x)=a*x+b
>> set fit errorvariables
>> fit f(x) "file.dat" using
>> ($1*(0.99458e5+1.08e3*9.81*$3*1e-2-0.94*3.08e3)*273.15/(1.01325e5*297.66)):(4.4828e3*$2)
>> via a,b
>>
>> set label 1 "Faraday-constant from slope of the fit" at graph 0.38,0.4
>> set label 2 "F = [ " at graph 0.38,0.35
>> set label 3 sprintf("%.2f +/- %.2f (%.2f%%)",a,a_err,a_err/a*100) at
>> graph 0.44,0.35
>> set label 4 "] C/mol" at graph 0.84,0.35
>> set label 5 "from that: Avogadro-constant:" at graph 0.38,0.28
>> set label 6 "N_A = " at graph 0.38,0.22
>> set label 7 sprintf("%.5e",a/1.602176487e-19) at graph 0.47,0.22
>> set label 8 "particles/mol" at graph 0.65,0.22
>>
>>
>> important: without the "set fit errorvariables" you won't have the
>> "_err"-Variables!
>>
>
>
--
View this message in context: http://www.nabble.com/Label-value-from-file-and-caption-under-the-graph-tp5680184p23244262.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|