Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #618

Re: Use variable from datafile in plot title

From sfeam <sfeam@users.sourceforge.net>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: Use variable from datafile in plot title
Followup-To comp.graphics.apps.gnuplot
Date 2011-10-02 10:00 -0700
Organization gnuplot development team
Message-ID <j6a5bt$747$1@dont-email.me> (permalink)
References <c760f4f3-806c-4422-875b-cce81debc830@k15g2000yqd.googlegroups.com>

Followups directed to: comp.graphics.apps.gnuplot

Show all headers | View raw


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

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Find similar


Thread

Use variable from datafile in plot title fcs pk <fcsprk@gmail.com> - 2011-10-02 06:53 -0700
  Re: Use variable from datafile in plot title sfeam <sfeam@users.sourceforge.net> - 2011-10-02 10:00 -0700

csiph-web