1

I have a dataset that defines two curves, and I want to fill the area between them. However, contrary to the standard situation, the abscissa is to be plotted on the vertical axis and the ordinates on the horizontal one; the abscissa indicates depth, this is a common plotting format in geophysics. In other words, I want something like

 plot 's.dat' u 1:2:3 w filledcurves

but with swapped axes so that the filled area is bounded not at the top and bottom but to the left and right by the curves as seen in

plot 's.dat' u 2:1,'s.dat' u 3:1

My dataset is like this:

0.      -1.776  -0.880
160.    -1.775  -0.882
160.    -1.692  -0.799
320.    -1.692  -0.800
320.    -1.531  -0.634
480.    -1.534  -0.637
480.    -1.286  -0.394

Is this possible in Gnuplot?

Thomas

TomR
  • 133
  • 1
  • 14
  • Perhaps this is helpful: [Gnuplot filledcurves flip axes](https://stackoverflow.com/questions/50676753/gnuplot-filledcurves-flip-axes) – user8153 Dec 13 '18 at 07:48

3 Answers3

1

If there is some value of x which is guaranteed to lie between the two curves then you can plot in two halves. For the data you show, x=-1 would be a suitable value and the plot command would be:

plot 's.dat' u 2:1 with filledcurve x=-1 lt 3, \
     's.dat' u 3:1 with filledcurve x=-1 lt 3

If the requirement for a constant intermediate x value can only be satisfied piece-wise, e.g.

 x=-1 for (0<y<500), x=0 for (500<y<1000)

then it may nevertheless be possible to construct a graph by stacking the piecewise sections.

enter image description here

Ethan
  • 13,715
  • 2
  • 12
  • 21
  • Yes, that may be a way to try, but it's too bad there seems to be no "proper" means to achieve this in Gnuplot (i.e., via an option). Unfortunately, what I posted is only a subset of the entire (and less well-behaved) dataset, so it would be rather cumbersome. Thanks anyway. – TomR Aug 28 '18 at 11:31
1

This is a totally different solution using 3D plot style "with zerror". You will need current gnuplot (version 5.2) for this. The plot style was really not designed for this so there are some difficulties (e.g. x tic marks invisible because drawn perpendicular to the plane of the plot, all tic labels requiring an offset for readability).

#
# [mis]use 3D plot style "with zerror" to create a plot of the xz
# plane with area fill between two sets of data points with
# equal coordinates on the vertical axis (x) but contrasting
# values on the horizontal axis (z).
#

set view 270, 0
set view azimuth -90
set xyplane at 0
unset ytics
set ztics offset  4, -2 out
set xtics offset  4

splot 's.dat' using 1:(0):(0.5*($2+$3)):2:3 with zerror notitle

enter image description here

Ethan
  • 13,715
  • 2
  • 12
  • 21
0

A simple way would be to define a closed line and fill it. For this, you take column 2 and add the reversed column 3. You probably need gnuplot >=5.2 for this.

Code:

### fill between vertical curves
reset session

$Data <<EOD
0.      -1.776  -0.880
160.    -1.775  -0.882
160.    -1.692  -0.799
320.    -1.692  -0.800
320.    -1.531  -0.634
480.    -1.534  -0.637
480.    -1.286  -0.394
EOD

set print $Outline
do for [i=1:|$Data|] {
    print sprintf("%s %s", word($Data[i],2), word($Data[i],1))
}
do for [i=|$Data|:1:-1] {
    print sprintf("%s %s", word($Data[i],3), word($Data[i],1))
}
set print

plot $Outline w filledcurve lc rgb "green"
### end of code

Result:

enter image description here

theozh
  • 22,244
  • 5
  • 28
  • 72