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


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

Re: if else with lines

Path csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Karl Ratzsch <mail.kfr@gmx.net>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: if else with lines
Date Mon, 28 Nov 2016 21:58:10 +0100
Organization solani.org
Lines 33
Message-ID <o1i5p2$isq$1@solani.org> (permalink)
References <o1i0ci$t97$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace solani.org 1480366690 19354 eJwFwYEBwCAIA7CXEGmBc6aj/59ggs3Fm0EwIKjcmst/xERqt77jo7xtp9ITczRppkYRi/UAEJcQkQ== (28 Nov 2016 20:58:10 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Mon, 28 Nov 2016 20:58:10 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0
X-User-ID eJwFwQEBACAIA7BKovxgHLzSP4IbFo0KJ+hodDsG74uL9qMx3+ywnRxzQVtUZ22pKiOv1fkhVxGb
Cancel-Lock sha1:u/lwJK4WqKCP3I2/erEsOHuzk0s=
X-NNTP-Posting-Host eJwFwYEBgDAIA7CXGNCC58wK/59gguChKgkmFit1DW6NGltMpmqBD+euG1vQY2HhvjR75wchKxDY
In-Reply-To <o1i0ci$t97$1@dont-email.me>
Xref csiph.com comp.graphics.apps.gnuplot:3490

Show key headers only | View raw


Am 28.11.2016 um 20:27 schrieb Jörg Buchholz:
> Hello
> 
> Sorry, I can't find the starting point for a solution to produce a plot
> where the y value dependence from the line before and behind the current
> line in a data set.
> 
> What I want to do is the following.
> 
> If y(n-1) < y(n) and y(n+1) < y(n) than y = y+a
> If y(n-1) > y(n) and y(n+1) > y(n) than y = y-a
> else y = y
> 
> Where n is the number of the line in a data set. "a" is a variable. The
> y value is in a column of a data set.
> 
> And this in a plot command, so that the y value dependence from the y
> value in the line before and after the current line in a data set.

You cannot read ahead of the current line, so you'll have to store
the last two values (resp. xy value pairs), and always only plot the
next-to-last one.

Key tool for this ghastly hack is the serial evaluation operator ",".

plot dataf us (lllx=llx,llx=lx,lx=$1,llly=lly,lly=ly,ly=$2, llx): \
  ((llly<lly && ly<lly) ? lly+a:(llly>lly)&&(ly>llyy) ? lly-a : lly)

Haven't tried now. You need to initialise all l* variables with NaN.
Honestly, I wouldn't go for gnuplot to do that. Use your favourite
spreadsheet calculator to transform the original dataset.

  Karl

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


Thread

if else with lines Jörg Buchholz <bookwood4new@freenet.de> - 2016-11-28 20:27 +0100
  Re: if else with lines Karl Ratzsch <mail.kfr@gmx.net> - 2016-11-28 21:58 +0100
    Re: if else with lines Jörg Buchholz <bookwood4new@freenet.de> - 2016-11-29 07:31 +0100

csiph-web