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


Groups > comp.graphics.apps.gnuplot > #3519 > unrolled thread

variable in plot command and key

Started byJörg Buchholz <bookwood4new@freenet.de>
First post2017-01-09 17:50 +0100
Last post2017-01-11 08:22 +0100
Articles 6 — 3 participants

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  variable in plot command and key Jörg Buchholz <bookwood4new@freenet.de> - 2017-01-09 17:50 +0100
    Re: variable in plot command and key Karl Ratzsch <mail.kfr@gmx.net> - 2017-01-09 23:50 +0100
      Re: variable in plot command and key Ethan A Merritt <EAMerritt@gmail.com> - 2017-01-09 21:59 -0800
        Re: variable in plot command and key Jörg Buchholz <bookwood4new@freenet.de> - 2017-01-10 08:17 +0100
          Re: variable in plot command and key Ethan A Merritt <EAMerritt@gmail.com> - 2017-01-10 08:54 -0800
            Re: variable in plot command and key Jörg Buchholz <bookwood4new@freenet.de> - 2017-01-11 08:22 +0100

#3519 — variable in plot command and key

FromJörg Buchholz <bookwood4new@freenet.de>
Date2017-01-09 17:50 +0100
Subjectvariable in plot command and key
Message-ID<o50eue$pm6$1@dont-email.me>
Hello,

how can I use a string variable as "plot data" and in the key, with a
underline in the variable and the default key entry?

example:

the plot data are in the file "test_test.dat". If I use the plot command

plot 'test_test.dat' u 1:2

gnuplot gives a correct plot with the key entry "'test_test.dat' u 1:2"
to me, it is the default key entry.


Now I want to have the name of the file as a variable, for example "data"

data = 'test_test.dat'
plot data u 1:2

The plot is correct but the key entry is "data u 1:2" instead
"'test_test.dat' u 1:2".


Next thing I have tried is:

data = 'test_test.dat'
plot data u 1:2 t data

The plot is correct but in the key there is a problem with the "_" and
the "u 1:2" is missing.


Is there a way to use a variable as data file name and have the default
key entry?

Jörg

[toc] | [next] | [standalone]


#3520

FromKarl Ratzsch <mail.kfr@gmx.net>
Date2017-01-09 23:50 +0100
Message-ID<o5143c$c45$1@solani.org>
In reply to#3519
Am 09.01.2017 um 17:50 schrieb Jörg Buchholz:
> 
> 
> Is there a way to use a variable as data file name and have the default
> key entry?
> 

You mean you want to see the actual file name + the actual "using"
specifier"? I think not, at least not directly.

You could write the whole plot command into a string and execute it
with "evaluate"

  fname = "'test_1.dat'"
  eval "plot ".fname." us 1:2"


[toc] | [prev] | [next] | [standalone]


#3521

FromEthan A Merritt <EAMerritt@gmail.com>
Date2017-01-09 21:59 -0800
Message-ID<o51t5r$bqd$1@dont-email.me>
In reply to#3520
Karl Ratzsch wrote:

> Am 09.01.2017 um 17:50 schrieb Jörg Buchholz:
>> 
>> 
>> Is there a way to use a variable as data file name and have the
>> default key entry?
>> 
> 
> You mean you want to see the actual file name + the actual "using"
> specifier"? I think not, at least not directly.
> 
> You could write the whole plot command into a string and execute it
> with "evaluate"
> 
>   fname = "'test_1.dat'"
>   eval "plot ".fname." us 1:2"

Or slightly simpler:

   foo = "'test_1.dat'"
   plot @foo using 1:2

To suppress interpretation of underscores in the plot key

   set key noenhanced

I don't think there is currently a way to maintain enhanced text
markup in the key titles while not having it replace underscores in file names.

  Ethan

[toc] | [prev] | [next] | [standalone]


#3522

FromJörg Buchholz <bookwood4new@freenet.de>
Date2017-01-10 08:17 +0100
Message-ID<o521mk$n69$1@dont-email.me>
In reply to#3521
On 10.01.2017 06:59, Ethan A Merritt wrote:
> Karl Ratzsch wrote:
> 
>> Am 09.01.2017 um 17:50 schrieb Jörg Buchholz:
>>>
>>>
>>> Is there a way to use a variable as data file name and have the
>>> default key entry?
>>>
>>
>> You mean you want to see the actual file name + the actual "using"
>> specifier"? I think not, at least not directly.
>>
>> You could write the whole plot command into a string and execute it
>> with "evaluate"
>>
>>   fname = "'test_1.dat'"
>>   eval "plot ".fname." us 1:2"
> 
> Or slightly simpler:
> 
>    foo = "'test_1.dat'"
>    plot @foo using 1:2
> 
> To suppress interpretation of underscores in the plot key
> 
>    set key noenhanced
> 
> I don't think there is currently a way to maintain enhanced text
> markup in the key titles while not having it replace underscores in file names.

Thanks for the answers. I give a simplified example to you, and now I
see I have oversimplified it. In your suggestions you give the filename
as a fix string, but in real it is build from some other variables.

At the moment this is my solution:

GR='1'          #Group
SEM='ws1617'    #Semester
MED1='Erbsen'   #Medium 1
MED2='Reis'     #Medium 2
RPout='../'.SEM.'/G'.GR.'_sieben-test.pdf'      #output file
RPdata1='../'.SEM.'/G'.GR.'_'.MED1.'.dat'       #data file 1
RPdata1t="'../".SEM.'/G'.GR.'\_'.MED1.".dat'"   #title data file 1
RPdata2='../'.SEM.'/G'.GR.'_'.MED2.'.dat'       #data file 2
RPdata2t="'../".SEM.'/G'.GR.'\_'.MED2.".dat'"   #title data file 2
...
plot RPdata1 u 1:7:(3000) w l lt 1 dt 1 smooth acsplines t 'D[%]',\
'' u 1:6:(3000) w l lt 2 dt 2 lc 1 smooth acsplines t 'R[%]',\
'' u 1:7 w p pt 4 lc 1 t RPdata1t.' u 1:7',\
'' u 1:6 w p pt 6 lc 1 t RPdata1t.' u 1:6'

Jörg

[toc] | [prev] | [next] | [standalone]


#3523

FromEthan A Merritt <EAMerritt@gmail.com>
Date2017-01-10 08:54 -0800
Message-ID<o533i7$dhl$1@dont-email.me>
In reply to#3522
Jörg Buchholz wrote:

> On 10.01.2017 06:59, Ethan A Merritt wrote:
>> Karl Ratzsch wrote:
>> 
>>> Am 09.01.2017 um 17:50 schrieb Jörg Buchholz:
>>>>
>>>>
>>>> Is there a way to use a variable as data file name and have the
>>>> default key entry?
>>>>
>>>
>>> You mean you want to see the actual file name + the actual "using"
>>> specifier"? I think not, at least not directly.
>>>
>>> You could write the whole plot command into a string and execute it
>>> with "evaluate"
>>>
>>>   fname = "'test_1.dat'"
>>>   eval "plot ".fname." us 1:2"
>> 
>> Or slightly simpler:
>> 
>>    foo = "'test_1.dat'"
>>    plot @foo using 1:2
>> 
>> To suppress interpretation of underscores in the plot key
>> 
>>    set key noenhanced
>> 
>> I don't think there is currently a way to maintain enhanced text
>> markup in the key titles while not having it replace underscores in
>> file names.
> 
> Thanks for the answers. I give a simplified example to you, and now I
> see I have oversimplified it. In your suggestions you give the
> filename as a fix string, but in real it is build from some other
> variables.
> 
> At the moment this is my solution:
> 
> GR='1'          #Group
> SEM='ws1617'    #Semester
> MED1='Erbsen'   #Medium 1
> MED2='Reis'     #Medium 2
> RPout='../'.SEM.'/G'.GR.'_sieben-test.pdf'      #output file
> RPdata1='../'.SEM.'/G'.GR.'_'.MED1.'.dat'       #data file 1
> RPdata1t="'../".SEM.'/G'.GR.'\_'.MED1.".dat'"   #title data file 1
> RPdata2='../'.SEM.'/G'.GR.'_'.MED2.'.dat'       #data file 2
> RPdata2t="'../".SEM.'/G'.GR.'\_'.MED2.".dat'"   #title data file 2
> ...
> plot RPdata1 u 1:7:(3000) w l lt 1 dt 1 smooth acsplines t 'D[%]',\
> '' u 1:6:(3000) w l lt 2 dt 2 lc 1 smooth acsplines t 'R[%]',\
> '' u 1:7 w p pt 4 lc 1 t RPdata1t.' u 1:7',\
> '' u 1:6 w p pt 6 lc 1 t RPdata1t.' u 1:6'
> 
> Jörg

The solution using macros should still work in your more complicated case.
The only extra requirement is that you wrap the entire constructed
file name in an additional set of quotation marks.
Like this:

quote = '"'

RPdata2='../'.SEM.'/G'.GR.'_'.MED2.'.dat'       # data file 2
RPdata2q = quote . RPdata2 . quote              # wrap it in extra quotes

plot ... @RPdata2q using 1:6, '' using 1:7, ...


    Ethan

[toc] | [prev] | [next] | [standalone]


#3524

FromJörg Buchholz <bookwood4new@freenet.de>
Date2017-01-11 08:22 +0100
Message-ID<o54mcm$411$1@dont-email.me>
In reply to#3523
On 10.01.2017 17:54, Ethan A Merritt wrote:
> Jörg Buchholz wrote:
> 
>> On 10.01.2017 06:59, Ethan A Merritt wrote:
>>> Karl Ratzsch wrote:
>>>
>>>> Am 09.01.2017 um 17:50 schrieb Jörg Buchholz:
>>>>>
>>>>>
>>>>> Is there a way to use a variable as data file name and have the
>>>>> default key entry?
>>>>>
>>>>
>>>> You mean you want to see the actual file name + the actual "using"
>>>> specifier"? I think not, at least not directly.
>>>>
>>>> You could write the whole plot command into a string and execute it
>>>> with "evaluate"
>>>>
>>>>   fname = "'test_1.dat'"
>>>>   eval "plot ".fname." us 1:2"
>>>
>>> Or slightly simpler:
>>>
>>>    foo = "'test_1.dat'"
>>>    plot @foo using 1:2
>>>
>>> To suppress interpretation of underscores in the plot key
>>>
>>>    set key noenhanced
>>>
>>> I don't think there is currently a way to maintain enhanced text
>>> markup in the key titles while not having it replace underscores in
>>> file names.
>>
>> Thanks for the answers. I give a simplified example to you, and now I
>> see I have oversimplified it. In your suggestions you give the
>> filename as a fix string, but in real it is build from some other
>> variables.
>>
>> At the moment this is my solution:
>>
>> GR='1'          #Group
>> SEM='ws1617'    #Semester
>> MED1='Erbsen'   #Medium 1
>> MED2='Reis'     #Medium 2
>> RPout='../'.SEM.'/G'.GR.'_sieben-test.pdf'      #output file
>> RPdata1='../'.SEM.'/G'.GR.'_'.MED1.'.dat'       #data file 1
>> RPdata1t="'../".SEM.'/G'.GR.'\_'.MED1.".dat'"   #title data file 1
>> RPdata2='../'.SEM.'/G'.GR.'_'.MED2.'.dat'       #data file 2
>> RPdata2t="'../".SEM.'/G'.GR.'\_'.MED2.".dat'"   #title data file 2
>> ...
>> plot RPdata1 u 1:7:(3000) w l lt 1 dt 1 smooth acsplines t 'D[%]',\
>> '' u 1:6:(3000) w l lt 2 dt 2 lc 1 smooth acsplines t 'R[%]',\
>> '' u 1:7 w p pt 4 lc 1 t RPdata1t.' u 1:7',\
>> '' u 1:6 w p pt 6 lc 1 t RPdata1t.' u 1:6'
>>
>> Jörg
> 
> The solution using macros should still work in your more complicated case.
> The only extra requirement is that you wrap the entire constructed
> file name in an additional set of quotation marks.
> Like this:
> 
> quote = '"'
> 
> RPdata2='../'.SEM.'/G'.GR.'_'.MED2.'.dat'       # data file 2
> RPdata2q = quote . RPdata2 . quote              # wrap it in extra quotes
> 
> plot ... @RPdata2q using 1:6, '' using 1:7, ...


On a "singleplot" it works, but "show variables" shows some oddities (gp
5.0 pl 4 WIN and gp 5.0 pl 3 Linux/Fedora 24)

gnuplot> quote = '"'
gnuplot> show variables quote

        Variables beginning with quote:
        quote = "\""

gnuplot> Rpdata1q = quote.Rpdata1.quote
gnuplot> show variables RPdata1q

        Variables beginning with RPdata1q:
        RPdata1q = "\"../ws1617/G0_Erbsen.dat\""

but it still works.

The Problem is, it seams to not work in the multiplot mode. And I use
multiplot. Ok, I don't tell it to you before. I must give more accuracy
to my examples. Sorry.

Jörg

[toc] | [prev] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web