Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ignore missing data in the desired way

561 views
Skip to first unread message

u.go...@gmail.com

unread,
Jan 20, 2017, 4:35:04 AM1/20/17
to
Hi there,

I can't get the script below to do what I want, namely make gnuplot draw continuous lines between the respective datasets "Yes", "No" and "Maybe". Can anybody help?

Best
Uwe

#!/gnuplot
#
#
# G N U P L O T
# Version 5.0 patchlevel 3 last modified 2016-02-21
#
# Copyright (C) 1986-1993, 1998, 2004, 2007-2016
# Thomas Williams, Colin Kelley and many others
#
# gnuplot home: http://www.gnuplot.info
# faq, bugs, etc: type "help FAQ"
# immediate help: type "help" (plot window: hit 'h')
set terminal png
set output "out.png"
set datafile missing "?"
set style data points
set xdata time
set timefmt "%Y-%m-%d"
set xrange ["2017-01-01":"2017-01-09"]
set format x "%m/%d"
set timefmt "%Y-%m-%d"
#set table 'tmp.dat'
$data << EOD
Date Yes No Maybe
2017-01-01 ? 9 ?
2017-01-02 2 ? 1
2017-01-03 3 7 ?
2017-01-04 ? 6 ?
2017-01-05 5 5 9
2017-01-06 6 4 ?
2017-01-07 7 ? 1
2017-01-08 ? 2 ?
2017-01-09 9 1 5
EOD
plot "$data" using "Date":"Yes" w l, "$data" using "Date":"No" with steps, "$data" using "Date":"Maybe" smooth sbezier

Karl Ratzsch

unread,
Jan 20, 2017, 6:05:35 AM1/20/17
to
Am 20.01.2017 um 10:35 schrieb u.go...@gmail.com:
>
> I can't get the script below to do what I want, namely make gnuplot draw continuous lines between the respective datasets "Yes", "No" and "Maybe". Can anybody help?
>

(simplified example)
set dataf missing '?'
$dat << EOD
No Maybe
0 2
1 ?
2 1
3 2
4 ?
5 9
6 ?
? 1
8 2
9 5
EOD

plot "$dat" using "No":"Maybe" w lp # missing dp are invalid
pause -1
plot "$dat" using 1:2 w lp # works



There are few connecting lines and no bezier curve, because an
invalid datapoint breaks those connections.

Aaand you know about that and "set datafile missing '?'", meaning
the connections should not be broken.

I find that it works if I use column numbers instead of header
strings in the "using" specifier. Looks like a bug to me.


Ethan A Merritt

unread,
Jan 20, 2017, 1:20:01 PM1/20/17
to
Version 5 was supposed to remove the difference between
using N and using ($N)
but it seems that this is a case where they are still treated
differently, as they were in earlier gnuplot versions.
So on the one hand it's always been this way, but on the other hand
it was intended to change. Let's call it a bug.

Note that using ($N) and using (column(N)) and using (column("head"))
all share the same input processing. So this bug is not specific
to column headers.

u.go...@gmail.com

unread,
Jan 20, 2017, 3:49:29 PM1/20/17
to
Thanks Karl and Ethan. I wrote a Ticket on https://sourceforge.net/p/gnuplot/bugs/1896/

sfeam

unread,
Jan 21, 2017, 7:26:01 PM1/21/17
to
u.go...@gmail.com wrote:

> Thanks Karl and Ethan. I wrote a Ticket on
> https://sourceforge.net/p/gnuplot/bugs/1896/

A fix for your specific problem is now in cvs for both 5.0 and 5.1
There is now also a related command
set datafile missing NaN
that tells gnuplot to treat any data point that evaluates to
not-a-number as if it were missing altogether. This change is
based on a suggestion and patch from Christoph Bersch.


Ethan
0 new messages