user3378936
user3378936

Reputation: 21

gnuplot: plot and splot matrix on the same graph

I am trying to plot two types of data in the same graph.

The first is a simple x-y points plot:

plot x

The second is a interpoled matrix, which I can plot with the following commands:

set pm3d map
set pm3d interpolate 0,0
splot "matrixfile" matrix

Both use the same xrange and yrange.

How can I plot them both in the same graph?

Upvotes: 2

Views: 2052

Answers (1)

Christoph
Christoph

Reputation: 48390

In order to combine these two plots, you must use the pseudo-datafile '+' to generate a 1D function with splot. Just using splot x would generate a surface:

set pm3d map
splot "matrixfile" matrix, '+' using 1:1

When using '+' a single column is generated, which samples the xrange.

Here a full example (which uses ++ instead of a data file for demonstration purpose):

set xrange [-5:5]
set yrange [-5:5]

set isosamples 100
set samples 100
unset key

set pm3d map

splot '++' using 1:2:(exp(-($1-$2)**2)), \
      '+' using 1:1:(0) with lines

This gives (with 4.6.3):

enter image description here

Upvotes: 1

Related Questions