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


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

Line type defined by data

Started byJanis Papanagnou <janis_papanagnou@hotmail.com>
First post2015-08-15 02:15 +0200
Last post2015-08-17 16:06 +0200
Articles 10 — 4 participants

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


Contents

  Line type defined by data Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-08-15 02:15 +0200
    Re: Line type defined by data Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2015-08-15 12:40 +0200
      Re: Line type defined by data Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-08-15 13:03 +0200
        Re: Line type defined by data Ethan A Merritt <EAMerritt@gmail.com> - 2015-08-15 10:54 -0700
          Re: Line type defined by data Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-08-15 23:43 +0200
            Re: Line type defined by data Ethan A Merritt <EAMerritt@gmail.com> - 2015-08-15 20:32 -0700
              Re: Line type defined by data Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-08-16 14:28 +0200
                Re: Line type defined by data Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-08-16 15:45 +0200
                  Re: Line type defined by data Karl-Friedrich Ratzsch <mail.kfr@gmx.net> - 2015-08-16 17:12 +0200
                    Re: Line type defined by data Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-08-17 16:06 +0200

#3009 — Line type defined by data

FromJanis Papanagnou <janis_papanagnou@hotmail.com>
Date2015-08-15 02:15 +0200
SubjectLine type defined by data
Message-ID<mqm0a7$bql$1@speranza.aioe.org>
Currently I am splitting my original data (three columns: date, amount, type)
into two files (file1, file2) and plot them individually using

  plot "file1" using 1:2 title 'A' with impulses lt 2 , \
       "file2" using 1:2 title 'B' with impulses lt 1

Is it possible to avoid the preprocessing of the original data and directly
determine the line type depending  on column 3 in the data file, say, like
(pseudo syntax)

  plot "file" using 1:2 title 'A' with impulses lt "some magic" using 3 , \
       "file" using 1:2 title 'B' with impulses lt "some magic" using 3

or any other way to avoid splitting of original "file" to "file1", "file2"?

Thanks!

Janis

[toc] | [next] | [standalone]


#3012

FromHans-Bernhard Bröker <HBBroeker@t-online.de>
Date2015-08-15 12:40 +0200
Message-ID<d38j88Fhs5tU1@mid.dfncis.de>
In reply to#3009
Am 15.08.2015 um 02:15 schrieb Janis Papanagnou:
> Currently I am splitting my original data (three columns: date, amount, type)

> Is it possible to avoid the preprocessing of the original data and directly
> determine the line type depending  on column 3 in the data file,

That depends on what that column three actually contains.  It might be 
as simple as specifying an "every" option, or you could use the ternary 
operator, or filter the file on-the-fly using the "< ..." special file.

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


#3014

FromJanis Papanagnou <janis_papanagnou@hotmail.com>
Date2015-08-15 13:03 +0200
Message-ID<mqn6a4$khd$1@speranza.aioe.org>
In reply to#3012
On 15.08.2015 12:40, Hans-Bernhard Bröker wrote:
> Am 15.08.2015 um 02:15 schrieb Janis Papanagnou:
>> Currently I am splitting my original data (three columns: date, amount, type)
> 
>> Is it possible to avoid the preprocessing of the original data and directly
>> determine the line type depending  on column 3 in the data file,
> 
> That depends on what that column three actually contains. 

Currently teh data is like this

   20050723 5470 1     or    20050723 5470 0

Column three is under my control. It may contain anything like

   20050723 5470 true  or    20050723 5470 false
   20050723 5470 red   or    20050723 5470 green
   20050723 5470 1     or    20050723 5470 2

i.e., I can adjust it if gnuplot has some demands on the specific data.

> It might be as
> simple as specifying an "every" option, or you could use the ternary operator,
> or filter the file on-the-fly using the "< ..." special file.

Could you please be more concrete; how would that look like?

Janis

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


#3016

FromEthan A Merritt <EAMerritt@gmail.com>
Date2015-08-15 10:54 -0700
Message-ID<mqnu9j$7c7$1@dont-email.me>
In reply to#3014
Janis Papanagnou wrote:

> On 15.08.2015 12:40, Hans-Bernhard Bröker wrote:
>> Am 15.08.2015 um 02:15 schrieb Janis Papanagnou:
>>> Currently I am splitting my original data (three columns: date,
>>> amount, type)
>> 
>>> Is it possible to avoid the preprocessing of the original data and
>>> directly
>>> determine the line type depending  on column 3 in the data file,
>> 
>> That depends on what that column three actually contains.
> 
> Currently teh data is like this
> 
>    20050723 5470 1     or    20050723 5470 0
> 
> Column three is under my control. It may contain anything like
> 
>    20050723 5470 true  or    20050723 5470 false
>    20050723 5470 red   or    20050723 5470 green
>    20050723 5470 1     or    20050723 5470 2
> 
> i.e., I can adjust it if gnuplot has some demands on the specific
> data.
> 
>> It might be as
>> simple as specifying an "every" option, or you could use the ternary
>> operator, or filter the file on-the-fly using the "< ..." special
>> file.
> 
> Could you please be more concrete; how would that look like?


 plot '< grep green datafile.dat'

or

 plot 'datafile.dat' using 1:(strcol(3) eq "green" ? $2 : NaN)

> 
> Janis

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


#3019

FromJanis Papanagnou <janis_papanagnou@hotmail.com>
Date2015-08-15 23:43 +0200
Message-ID<mqobpq$9r6$1@speranza.aioe.org>
In reply to#3016
On 15.08.2015 19:54, Ethan A Merritt wrote:
> Janis Papanagnou wrote:
> 
>> On 15.08.2015 12:40, Hans-Bernhard Bröker wrote:
>>> Am 15.08.2015 um 02:15 schrieb Janis Papanagnou:
>>>> Currently I am splitting my original data (three columns: date,
>>>> amount, type)
>>>
>>>> Is it possible to avoid the preprocessing of the original data and
>>>> directly
>>>> determine the line type depending  on column 3 in the data file,
>>>
>>> That depends on what that column three actually contains.
>>
>> Currently teh data is like this
>>
>>    20050723 5470 1     or    20050723 5470 0
>>
>> Column three is under my control. It may contain anything like
>>
>>    20050723 5470 true  or    20050723 5470 false
>>    20050723 5470 red   or    20050723 5470 green
>>    20050723 5470 1     or    20050723 5470 2
>>
>> i.e., I can adjust it if gnuplot has some demands on the specific
>> data.
>>
>>> It might be as
>>> simple as specifying an "every" option, or you could use the ternary
>>> operator, or filter the file on-the-fly using the "< ..." special
>>> file.
>>
>> Could you please be more concrete; how would that look like?
> 
> 
>  plot '< grep green datafile.dat'
> 
> or
> 
>  plot 'datafile.dat' using 1:(strcol(3) eq "green" ? $2 : NaN)

Thanks for your reply. Do I interpret that code correctly; the first one
triggers an external command to read only the respective matching lines
from the data file, and the second one compares data column 3 gainst the
string ("green" in this case) and provides only the data field 2 to plot
if it matches, and "NaN" will make the plot command ignore that point?
If my interpretation is correct, I will need with either variant two plot
specifications, one to grep green and one to grep red, and respectively
similarly with the ternary operation. Right? Thanks!

Janis

> 
>>
>> Janis
> 

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


#3029

FromEthan A Merritt <EAMerritt@gmail.com>
Date2015-08-15 20:32 -0700
Message-ID<mqp04r$jup$1@dont-email.me>
In reply to#3019
Janis Papanagnou wrote:

> On 15.08.2015 19:54, Ethan A Merritt wrote:
>> Janis Papanagnou wrote:
>> 
>>> On 15.08.2015 12:40, Hans-Bernhard Bröker wrote:
>>>> Am 15.08.2015 um 02:15 schrieb Janis Papanagnou:
>>>>> Currently I am splitting my original data (three columns: date,
>>>>> amount, type)
>>>>
>>>>> Is it possible to avoid the preprocessing of the original data and
>>>>> directly
>>>>> determine the line type depending  on column 3 in the data file,
>>>>
>>>> That depends on what that column three actually contains.
>>>
>>> Currently teh data is like this
>>>
>>>    20050723 5470 1     or    20050723 5470 0
>>>
>>> Column three is under my control. It may contain anything like
>>>
>>>    20050723 5470 true  or    20050723 5470 false
>>>    20050723 5470 red   or    20050723 5470 green
>>>    20050723 5470 1     or    20050723 5470 2
>>>
>>> i.e., I can adjust it if gnuplot has some demands on the specific
>>> data.
>>>
>>>> It might be as
>>>> simple as specifying an "every" option, or you could use the
>>>> ternary operator, or filter the file on-the-fly using the "< ..."
>>>> special file.
>>>
>>> Could you please be more concrete; how would that look like?
>> 
>> 
>>  plot '< grep green datafile.dat'
>> 
>> or
>> 
>>  plot 'datafile.dat' using 1:(strcol(3) eq "green" ? $2 : NaN)
> 
> Thanks for your reply. Do I interpret that code correctly; the first
> one triggers an external command to read only the respective matching
> lines from the data file, and the second one compares data column 3
> gainst the string ("green" in this case) and provides only the data
> field 2 to plot if it matches, and "NaN" will make the plot command
> ignore that point? If my interpretation is correct, I will need with
> either variant two plot specifications, one to grep green and one to
> grep red, and respectively similarly with the ternary operation.

Right.

Or, since you say you can fill in that column as you choose, 
you could provide a file that looked like this:

   20050723 5470 0xff0000  # red 
   20050723 5471 0x00ff00  # green
   20050723 5472 0x00ff00
   20050723 5473 0x00ff00
   20050723 5474 0x0000ff  # blue

and plot it all at once using

  plot 'datafile.dat' using 1:2:3 lc rgb varialbe


	Ethan


> Right? Thanks!
> 
> Janis
> 
>> 
>>>
>>> Janis
>>

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


#3033

FromJanis Papanagnou <janis_papanagnou@hotmail.com>
Date2015-08-16 14:28 +0200
Message-ID<mqpvkr$cli$1@speranza.aioe.org>
In reply to#3029
On 16.08.2015 05:32, Ethan A Merritt wrote:
> Janis Papanagnou wrote:
>> [...]
> 
> Right.

Thanks for the confirmation.

> 
> Or, since you say you can fill in that column as you choose, 
> you could provide a file that looked like this:
> 
>    20050723 5470 0xff0000  # red 
>    20050723 5471 0x00ff00  # green
>    20050723 5472 0x00ff00
>    20050723 5473 0x00ff00
>    20050723 5474 0x0000ff  # blue
> 
> and plot it all at once using
> 
>   plot 'datafile.dat' using 1:2:3 lc rgb varialbe
> 

This looks like an interesting variant! - I'll try that. Thanks!

Janis

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


#3036

FromJanis Papanagnou <janis_papanagnou@hotmail.com>
Date2015-08-16 15:45 +0200
Message-ID<mqq45h$mhq$1@speranza.aioe.org>
In reply to#3033
On 16.08.2015 14:28, Janis Papanagnou wrote:
> On 16.08.2015 05:32, Ethan A Merritt wrote:
>>
>> Or, since you say you can fill in that column as you choose, 
>> you could provide a file that looked like this:
>>
>>    20050723 5470 0xff0000  # red 
>>    20050723 5471 0x00ff00  # green
>>    20050723 5472 0x00ff00
>>    20050723 5473 0x00ff00
>>    20050723 5474 0x0000ff  # blue
>>
>> and plot it all at once using
>>
>>   plot 'datafile.dat' using 1:2:3 lc rgb varialbe
>>
> 
> This looks like an interesting variant! - I'll try that. Thanks!

It works fine. Compared to the other two variants upthread I like that
the plot command is structurally very simple! - A minor issue is only
that with the other variants I get two titles in the diagram, one for
the "red" and one for the "green" case, and here I get only one. While
that's not that impotant in my actual case (so I use an empty 'title')
I'd be interested to know whether there's also an option to create two
titles with the one plot command suggested here.

Janis

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


#3037

FromKarl-Friedrich Ratzsch <mail.kfr@gmx.net>
Date2015-08-16 17:12 +0200
Message-ID<mqq99p$lhg$1@solani.org>
In reply to#3036
Am 16.08.2015 um 15:45 schrieb Janis Papanagnou:
> On 16.08.2015 14:28, Janis Papanagnou wrote:
>> On 16.08.2015 05:32, Ethan A Merritt wrote:
>>>
>>>   plot 'datafile.dat' using 1:2:3 lc rgb varialbe
>>>
>>
>> This looks like an interesting variant! - I'll try that. Thanks!
> 
> It works fine. Compared to the other two variants upthread I like that
> the plot command is structurally very simple! - A minor issue is only
> that with the other variants I get two titles in the diagram, one for
> the "red" and one for the "green" case, and here I get only one. While
> that's not that impotant in my actual case (so I use an empty 'title')
> I'd be interested to know whether there's also an option to create two
> titles with the one plot command suggested here.

You can get only one title per plot. Also with "lc rgb variable" the
colour of the legend symbol always assumes the last value from the
data file.

You'll again have to split the plot in two using the ternary
operator in the using statement

plot "dataf" us ($3==color1?$1:NaN):2:3 lc rgb variable tit "C 1",\
     "dataf" us ($3==color2?$1:NaN):2:3 lc rgb variable tit "C 2"




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


#3038

FromJanis Papanagnou <janis_papanagnou@hotmail.com>
Date2015-08-17 16:06 +0200
Message-ID<mqspq2$baq$1@speranza.aioe.org>
In reply to#3037
On 16.08.2015 17:12, Karl-Friedrich Ratzsch wrote:
> Am 16.08.2015 um 15:45 schrieb Janis Papanagnou:
>> On 16.08.2015 14:28, Janis Papanagnou wrote:
>>> On 16.08.2015 05:32, Ethan A Merritt wrote:
>>>>
>>>>   plot 'datafile.dat' using 1:2:3 lc rgb varialbe
>>>>
>>>
>>> This looks like an interesting variant! - I'll try that. Thanks!
>>
>> It works fine. Compared to the other two variants upthread I like that
>> the plot command is structurally very simple! - A minor issue is only
>> that with the other variants I get two titles in the diagram, one for
>> the "red" and one for the "green" case, and here I get only one. While
>> that's not that impotant in my actual case (so I use an empty 'title')
>> I'd be interested to know whether there's also an option to create two
>> titles with the one plot command suggested here.
> 
> You can get only one title per plot. Also with "lc rgb variable" the
> colour of the legend symbol always assumes the last value from the
> data file.

Thanks for clarifying that!

> 
> You'll again have to split the plot in two using the ternary
> operator in the using statement
> 
> plot "dataf" us ($3==color1?$1:NaN):2:3 lc rgb variable tit "C 1",\
>      "dataf" us ($3==color2?$1:NaN):2:3 lc rgb variable tit "C 2"

I see.

Janis

[toc] | [prev] | [standalone]


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


csiph-web