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


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

Re: Set plot title from datafile?

From Ethan Merritt <eamerritt@gmail.com>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: Set plot title from datafile?
Date 2018-08-03 16:24 +0000
Organization A noiseless patient Spider
Message-ID <pk1vkl$n18$1@dont-email.me> (permalink)
References <7f451633-8c55-48bc-92ad-ac5351eaff07@googlegroups.com> <pjvcdk$r4h$1@dont-email.me> <f60d1d36-0bfc-4432-829e-6b1c54878db2@googlegroups.com>

Show all headers | View raw


On Thu, 02 Aug 2018 18:35:52 -0700, rowlesmr wrote:

> On Friday, 3 August 2018 00:44:38 UTC+8, Ethan Merritt  wrote:
>> On Thu, 02 Aug 2018 08:02:12 -0700, rowlesmr wrote:
>> 
>> > How can I set the title of my plot from a string in my data file?
>> > 
>> > My data is like so:
>> 
>> [snip]
>> 
>> 
>> > and I'm plotting it with a nested for loop like so:
>> > 
>> >>set key autotitle columnhead do for [j=0:1] {
>> >>  do for [i=4:8] {
>> >>    plot 'data.txt' index j u 2:i w lp t columnhead
>> >>  }
>> >>}
>> > 
>> > I am successfully setting the key from the header information. I
>> > would like the title for each graph to be taken from the text string
>> > in the 3rd column (ie corundum or silcon_NIST). I know that this
>> > would give many graphs with the same title.
>> > 
>> > 
>> > Is this possible? If so, how can I do it?
>> > 
>> > I am using gnuplot 5.2 patchlevel 2 in Cygwin
>> 
>> 
>> It is not possible in 5.2
>> 
>> In the development version (5.3) you could do it in two steps,
>> which might or might not be OK in your application case:
>> 
>> do for [i=4:8] {
>>     unset title plot 'data.txt' index j u 2:i w lp title
>>     (FOO=columhead(i))
>>     set title FOO replot
>> }
>> 
>> 	Ethan
> 
> Thanks Ethan
> 
> Is it possible to set the title as a particular columnhead? eg the third
> one? I could do some preprocessing to put the string I want into that
> position.
> 
> Matthew

I just realized that if a two-pass solution is acceptable then version 5.2
can be tricked into doing the same thing. It's a bit more obscure because
the manipulation must go inside the using specifier rather than
inside the plot title evaluation.  The first plot command exists for the 
sole purpose of forcing evaluation of "FOO=columnhead(i))". Once FOO is
known, the second command can use it for both the plot title and the
key entry.

  do for [i=4:8] {
    unset title
    plot 'data.txt' index j using 2:i:(FOO=columnhead(i)) w lp notitle
    set title FOO
    plot 'data.txt' index j using 2:i w lp title FOO
  }

      Ethan

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


Thread

Set plot title from datafile? rowlesmr@gmail.com - 2018-08-02 08:02 -0700
  Re: Set plot title from datafile? Ethan Merritt <eamerritt@gmail.com> - 2018-08-02 16:44 +0000
    Re: Set plot title from datafile? rowlesmr@gmail.com - 2018-08-02 18:35 -0700
      Re: Set plot title from datafile? Ethan Merritt <eamerritt@gmail.com> - 2018-08-03 16:24 +0000

csiph-web