vanna
vanna

Reputation: 1572

Set/unset dgrid3d on the same graph

I would like to plot two different data sets on the same graph in 3d. This can easily be done with

splot 'foo.dat','bar.dat'

Unfortunately I would like foo to be smooth so I used dgrid3d to set a grid. At the same time I would like bar to just show dots (foo is actually an interpolation of bar, and I would like to plot the knots). Thus I used

set dgrid3d 20,20
splot 'foo.dat' w l, 'bar.dat' w points

Unfortunately this apply dgrid3d to both data sets... Is it possible to unset dgrid3d in the splot command or to solve this problem using another trick ?

Upvotes: 1

Views: 589

Answers (1)

mgilson
mgilson

Reputation: 309929

You'll need another trick. That trick is set table

set terminal push           #save terminal info
set terminal unknown        #null terminal
set table 'foo_gridded.dat' #temporary file to store the data
set dgrid3d 20,20   
splot 'foo.dat'
unset table                 #close temporary file
unset dgrid3d
set terminal pop            #restore terminal info
splot 'foo_gridded.dat' w l, 'bar.dat' w points  #make the plot we want
!rm foo_gridded.dat         #Optional, remove temporary file (Only works on Unix-like systems)

set table basically "plots" the data to a text file which is formatted for gnuplot to read back in. It's extremely useful -- in the end, I think it's purpose is for creating all sorts of (ugly) little hacks like the one above so the gnuplot developers don't need to worry about plot-type clashes. (I use this one to plot contours on top of pm3d maps).

Upvotes: 4

Related Questions