1
votes

I've got two datafiles that I need to plot, First datafile "surface.dat" is an Nx3 matrix which contains the x y z data.

Am splotting with pm3d and set viewmap to get the 2D projection map of my current surface where the z data defines the range of the colorbar.

The second data file "closed_curve.dat" lies on the x-y plane with no z components. Its very easy to plot the surface and curve in the same graph by using

set view map
set cbrange...
set xrange...
set yrange...
splot "surface.dat"  u 2:1:3 title "" w pm3d ,"closed_curve.dat" u 1:2:(0) title  ""

Since its a closed curve however, I want to fill it with one of the gnuplot patterns but I can't find anything that works.

A closed curve in the form of a rectangle for example can just be created as an object without the need of a data file and filled in so that's not a problem e.g

set object 1 rectangle from 0,0 to 0.4,0.8 front fc  lt 1 fs pattern 2 lw 2

Thanks in advance....

1

1 Answers

0
votes

I think your best option is using an external tool to create a polygon object based on your data file:

set macros
polystr = system('awk -v "ORS= " "{printf \"%s %f,%f \",s,\$1,\$2; s = \"to\"}" closed_curve.dat')
set object 1 polygon fillstyle pattern 5 from @polystr
splot "surface.dat" using 2:1:3 with pm3d

I'm not sure if there is any limit on the allowed line length which you may hit with polystr. Maybe you'll need to write the command to a temporary file and the load this.