0
votes

I try to create a nice waterfall map with gnuplot showing the development of an optical spectrum with current. My goal is to achieve something close to this :

A waterfall plot

I have tried this command

splot [][1160:1200][-80:-30] "Waterfall.txt" u 1:2:3 w l lw 3 lc rgb 'black' 

The "Waterfall.txt" file has the format suggested in the accepted answer here Gnuplot: fence plot from data. I have ignored z-data values lower than -80, substituting them with NaN.

The outcome is shown in the next image link.

My attempt

As you can see, compared with the previous figure, this is confusing to the reader. How can I fix it in order for it to be close to the first image and thus more clear to the viewer ?

Edit:

Thanks to @Ethan's answer it worked. The outcome is shown in the figure below. The only problem is the transparency of each fence, that reveals partially the subsequent fences.

The new attempt

1
Since version 5.2 you can use zerrorfill for fence plots, see gnuplot.sourceforge.net/demo_5.2/fenceplot.html - Christoph
It is not clear from your description how you replaced some of the values with NaN, but this is probably a bad idea. It is likely the cause of the disconnected line fragments in the plot you show, since gnuplot does not connect two points in a data set that have intervening NaN values. If the NaN values are already in the data file, you may be able to recover by using the gnuplot command set datafile missing NaN. As Christophe says, the current recommended way to construct a fence plot is to use the zerrorfill plotting style. Please try that and amend your question if it does not work. - Ethan
@Ethan can you shortly explain how to use the zerrorfill ? I have twenty 2D files with the YZ (Y = Wavelength, Z = Power) data. Each 2D file corresponds to a X value ( X = Current). I have used MATLAB to open these files and format the data to a txt file in the manner similar to the accepted answer I posted earlier. The range of z values is from -120 to -30. - George Sarantoglou

1 Answers

1
votes

Assume twenty 2D files each containing Y and Z:

Gnuplot version 5.2

  filename(i) = 'silver.dat'
  set pm3d scansauto
  set style fill solid noborder
  set xyplane at 0
  set log z
  unset key
  splot for [k=20:1:-1] filename(k) using 1:(k):2:(1.0):2 with zerrorfill \
        fc "white" lc "black" lw 2
  • I don't have your data files so I use the same file 20 times for the purpose of illustration. It is based on the zerror demo in the gnuplot distribution and online demo set.
  • Note that the base of each 'fence' is set to (z=1.0) rather than zero because of the log scale on z.
  • The figure shown was made using a newer gnuplot. It uses partial transparency and a fancier bounding box that isn't in 5.2 enter image description here