0
votes

I have some data files with around 10k records; each record containing a value plus the standard deviation for it.

I'm plotting the standard deviation as a slightly transparent filledcurve. However, since there were some weird artifacts with painting so many points, I've resorted to using the every command to plot every 99 points.

'$1' using 1:(\$3-\$5):(\$3+\$5) every 99::0 with filledcurves ls $COUNTER notitle

This works perfectly; however my problem is that depending on how many exact records I have in the file, the every command may skip the last entries, which ends up with the colored standard deviation area ending before its respective line.

Missing std

Is there any way to include the last record to the every command/filled plot so that the colored area extends to where it needs to?

EDIT: The effect I'm trying to avoid is this:

flickery plot

I can't seem to really reproduce it atm as I'm working with new data, but I'm sure that picking points every once in a while avoids it.

2
what are the weird artefacts? Maybe they can be eliminated instead of running into new "surprises"? - theozh
It's been a while since I did the change; however I remember that in some cases the resulting plot looked nearly iridescent. I assume this was because gnuplot fills the filledcurves with a series of filled triangles, and in some conditions this would result in the borders between the triangles to become visible (as I'm not using full opacity), which combined with the thousands of points would make the plot very flickery. - Svalorzen

2 Answers

2
votes

[amended to show full treatment of NaN value. Demo'ed with a real data file]

Instead of every, you can construct a filter function for the using specifier.

set xrange [100:600]
xmax = 600
filter(x) = (int(column(0))%9 == 0  ||  x == xmax) ? 1 : 0
set datafile missing NaN
plot 'silver.dat' using (filter($1)?$1:NaN) : ($2-$3) : ($2+$3) with filledcurves, \
     '' using 1:2 with lines

enter image description here

0
votes

You mentioned the iridescent patterns when plotting about 10k datapoints with transparent? Although different terminals look different, I can't observe this behaviour with gnuplot 5.2.6 under Win7 or we are talking about different things. Maybe, your data or terminal or OS is special?

Test code:

### transparent error range
reset session
# set term wxt size 600,600
# set term qt size 600,600
set term pngcairo size 600,600
set output "ErrorRangePNGCairo.png"
set key left

GenerateData = 'set print $Data; \
    do for [i=1:Max] { print sprintf("%g\t%g\t%.3f",i,i+rand(0)*Max*0.1,rand(0)*Max*0.1+Max*0.05) }; \
    set print'

PlotData = 'plot \
        $Data u 1:($2+$3):($2-$3) w filledcurves lc rgb "#aaff0000" t "Error",\
        "" u 1:2 w l lc rgb "red" t "Data"'

set multiplot layout 3,1
    Max = 100
    @GenerateData
    @PlotData

    Max = 1000
    @GenerateData
    @PlotData

    Max = 10000
    @GenerateData
    @PlotData
unset multiplot
set output
### end of code

wxt terminal:

enter image description here

qt terminal:

enter image description here

pngcairo terminal:

enter image description here