Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: sfeam Newsgroups: comp.graphics.apps.gnuplot Subject: Re: Use variable from datafile in plot title Followup-To: comp.graphics.apps.gnuplot Date: Sun, 02 Oct 2011 10:00:42 -0700 Organization: gnuplot development team Lines: 24 Message-ID: References: Reply-To: sfeam@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Sun, 2 Oct 2011 17:00:45 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="a5sqwvDD9P994JK/mw/xtg"; logging-data="7303"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BP89qOGoNJHtrMslbkmDs" User-Agent: KNode/4.4.9 Cancel-Lock: sha1:8IsbbhSt99/8dqn4aejfdij1CCA= Xref: x330-a1.tempe.blueboxinc.net comp.graphics.apps.gnuplot:618 fcs pk wrote: > Dear All, > > I would like to use a variable from a data file as title for a plot. > Something like: > > var1 = './data_2' index 1000 using 4 > plot './data_1' index 1000 using 1:2 title var1 > > Well, obviously, the example I just gave doesnt work. But I would > like to know whether it is possible to do something similar in > gnuplot? Suppose that somewhere in your file is a line like # Next plot has title: XX YY ZZ You can use the string processing routines in gnuplot to get load "XX YY ZZ" into a string variable: gnuplot> grep_command = "grep title: myfile.dat" gnuplot> titleline = system(grep_command) gnuplot> index = strstrt(titleline, ": ") gnuplot> plot_title = titleline[index+1:*] gnuplot> plot .... title plot_tile