Student
Student

Reputation: 1

Fence plot using Gnuplot for one datafile

folks, I was hoping someone could help me out. I am trying to use a datafile to create a fence plot with Gnuplot (version 5.2 patchlevel 7) that hopefully would look something like this:

Fence plot using Gnuplot

However, using the script

set terminal pngcairo enhanced size 800,600
set output 'output1.png'

splot for [i=0:615000:12300] "datafile" index i u 1:2:3 with lines

the results were disappointing. My output:

Failed attempt at fence plot with Gnuplot

My datafile is very big and slightly different from the one used to make the plot I'm trying to recreate: It has 615000 lines, with 5000 "blocks" of data, each containing the value of a function at a specific time for 123 grid sites, from grid site 240 to grid site 362, without blank lines between the blocks. It looks like this:

     0.000   240      0.20000000E-39
     0.000   241      0.20000000E-39
     0.000   242      0.20000000E-39
...
     0.000   361      0.20000000E-39
     0.000   362      0.20000000E-39
     0.020   240      0.20000000E-39
     0.020   241      0.20000000E-39
...

and so on.

If I want some 50 lines to show up on the plot, like , I would imagine I need to skip several blocks, and only plot the relevant block after many timesteps, but I don't know how to do it.

I realize that there are several questions that have been asked about fence plots with Gnuplot, and I went over all of them, but I completely failed in adapting their suggestions to my current case. Any help would be much appreciated.

Upvotes: 0

Views: 61

Answers (1)

Ethan
Ethan

Reputation: 15093

The trick is to use plot style "splot with zerror", which draws both a solid line and a filled area associated with that line. For a fence plot the line will be z(x) and the filled area will run from 0 to z(x). The basic format of the plot command will be splot ... using x:y:z:(0):z with zerror.

As I understand it, your data consists of 123 scans where each scan contains 5000 points. The x coordinate is in column 1; the scan number is in column 2; the z coordinate is in column 3. The order within the file places all samples at x=0 first, all samples at x=delta_x second, etc. Gnuplot counting starts at zero, so the points in scan 0 (the first scan) consist of every 123rd point starting at point 0.

To select all points in scan N, we would therefore use the specification every 123::N*123.

We will use the scan number ("grid site") as the y coordinate. In order to have the scan closest to the viewer occlude the ones further back, the scans must be draw in order from highest y to lowest y.

Assuming 5000 time increments of 0.02 the total range on x is [0:100]. To plot the full range of x samples, the commands will look something like this

unset key
set xyplane at 0
set style fill solid
set xrange [0.0 : 100.0]

splot for [scan=122:0:-1] 'DATA' every 123::scan*123 \
      using 1:(scan):2:(0):2 with zerror lc "black" fc bgnd

I don't understand your request for "only 50 lines". The plot you show as a n example has one line for each scan, i.e. one line per grid site. You could cut this in half by plotting for [scan=122:0:-2].

The expected output will look like this (totally made up data) expected plot

Upvotes: 0

Related Questions