Eric Tovar
Eric Tovar

Reputation: 33

Gnuplot filled curves adds unwanted "bottom" border

I am trying to visualize a time series data set on one plot as a pseudo 3d figure. However, I am having some trouble getting the filledcurves capability working properly. It seems to be adding an unwanted border at the "bottom" of my functions and I do not know how to fix this.

This is my current set up: I have nb_of_frames different files that I want to plot on one figure. Without the filledcurves option, I can do something like this

plot for [i=1:nb_of_frames] filename(i) u ($1):(50.0 * $2 + (11.0 - (i-1)*time_step)) w l linewidth 1.2 lt rgb "black" notitle

which produces a figure like this: no fill options

enter image description here

Instead of doing this, I want to use the filledcurves option to bring my plots "forward" and highlight the function that is more "forward" which I try to do with:

plot for [i=1:nb_of_frames] filename(i) u ($1):(50. * $2 + (11. - (i-1)*time_step)) w filledcurves fc "white" fs solid 1.0 border lc "black" notitle

This produces a figure as follows: enter image description here

This is very close to what I want, but it seems that the border option adds a line underneath the function which I do not want. I have tried several variants of with filledcurves y1=0.0 with different values of y1, but nothing seems to work.

Any help would be appreciated. Thank you for your time.

Upvotes: 3

Views: 421

Answers (2)

theozh
theozh

Reputation: 25714

Here is another workaround for gnuplot 5.2.

Apparently, gnuplot closes the filled area from the last point back to the first point. Hence, if you specifiy border, then this line will also have a border which is undesired here (at least until gnuplot 5.4rc2 as @Ethan says).

A straightforward solution would be to plot the data with filledcurves without border and then again with lines. However, since this is a series of shifted data, this has to be plotted alternately. Unfortunately, gnuplot cannot switch plotting styles within a for loop (at least I don't know how). As a workaround for this, you have to build your plot command in a previous loop and use it with a macro @ (check help macros) in the plot command. I hope you can adapt the example below to your needs.

Code:

### filledcurves without bottom border
reset session
set colorsequence classic

$Data <<EOD
1  0
2  1
3  2
4  1
5  4
6  5
7  2
8  1
9  0
EOD

myData(i) = sprintf('$Data u ($1-0.1*%d):($2+%d/5.)',i,i)
myFill    = ' w filledcurves fc "0xffdddd" fs solid 1 notitle'
myLine    = ' w l lc rgb "black" notitle'

myPlotCmd = ''
do for [i=11:1:-1] {
    myPlotCmd = myPlotCmd.myData(i).myFill.", ".myData(i).myLine.", "
}

plot @myPlotCmd

### end of code

Result:

enter image description here

Upvotes: 2

Ethan
Ethan

Reputation: 15093

I can reproduce this in gnuplot 5.2.8 but not in the output from the release candidate for version 5.4. So I think that some bug-fix or change was applied during the past year or so. I realize that doesn't help while you are using verion 5.2, but if you can download and build from source for the 5.4 release candidate that would take care of it.

enter image description here

Update I thought of a work-around, although it may be too complicated to be worth it. You can treat this as a 2D projection of a 3D fence plot constructed using plot style with zerrorfill. In this projection the y coordinate is the visual depth. X is X. Three quantities are needed on z: the bounding line, the bottom, and the top. I.e. 5 fields in the using clause: x depth zline zbase ztop.

unset key
set view 90, 180
set xyplane at 0
unset ytics

set title "3D projection into the xz plane\nplot with zerrorfill" offset 0,-2

set xlabel "X axis" offset 0,-1
set zlabel "Z"

splot for [i=1:25] 'foo.dat' using ($1+i):(i/100.):($2-i):(-i):($2-i) \
                    with zerrorfill fc "light-cyan" lc "black"  lw 2

enter image description here

Upvotes: 2

Related Questions