Nick Dong
Nick Dong

Reputation: 3736

how to plot new line given by math formula over pm3d map

ENV

gnuplot 5.0 patchlevel 1

How to plot discrete points on top of pm3d map in gnuplot?, with code and his mini data

set term postscript enhanced color
set output "gc4-4.eps"
set pm3d map interpolate 10,10
set palette rgbformulae 22,13,-31
sp 'file.dat', 'points.dat' using 1:2:(0) with lines

and Draw a line in a pm3d map, How to mark some points on 2D heat map in gnuplot? are similar solutions. But they use data file instead of math formula.

I also tried How to overlay dots/points scatter plot onto a pm3d map/surface, How to overlay contour plot over pm3d map/surface, How do I plot lines (not grids) using splot?

try some combination of unset surface, set surface explicit, plot ... nosurface. . And those are seems solutions for 3d coordinations.

I still do not get the expected result.

Did I miss something? Thank you in advance.

My code below:

set term postscript enhanced color
set output "g.eps"
set multiplot layout 1,2 
set pm3d map explicit interpolate 10,10
set palette rgbformulae 22,13,-31
#set contour
#set cntrparam levels incr 0,0.1,0.1
#set linetype 2 linecolor rgb "white" linewidth 2
set tics scale 0.5 
set label 1 '(a)' at graph -0.3,1 front
set xlabel "x" 
set ylabel "{/Symbol y}" 
set xtics 0.8,1.0,2.8
set xrange [0.8:2.8]
set ytics 0.1,0.1,0.9
set yrange [0.1:0.9]
set size 0.4,0.4
#unset surface
#set surface explicit
fx(x) = (x-1.8)**2+0.1
sp "s.data" u 1:2:3 with pm3d notit, fx(x) with line linetype 2 linecolor rgb "white" linewidth 2 tit "line"
#plot fx(x) with lines linetype 2 linecolor rgb "black" linewidth 2 tit "line"
plot fx(x) with lines linetype 2 linecolor rgb "black" linewidth 2 tit "line"
set label 1 '(b)' at graph -0.3,1 front
set xlabel "x"
set ylabel "{/Symbol y}"
set xtics 0.1,0.1,0.9
set xrange [0.1:0.9]
set ytics 0.8,1.0,2.8
set yrange [0.8:2.8]
set size 0.4,0.4
unset surface
set surface explicit
fx(x) = -(2*x-1)**2+1.8
sp "s.data" u 2:1:3 notit, fx(x) with lines linetype 2 linecolor rgb "white" linewidth 2 nosurface tit "line"
#plot fx(x) with lines linetype 2 linecolor rgb "black" linewidth 2 tit "line"
#sp "data/s2.data" u 2:1:3  notit

My mini data of s.data:

# x y z
0.8 0.1 0.3 
0.8 0.2 0.2 
0.8 0.3 0.1 
0.8 0.4 0
0.8 0.5 0
0.8 0.6 0
0.8 0.7 0
0.8 0.8 0
0.8 0.9 0

1.8 0.1 0.3 
1.8 0.2 0.2 
1.8 0.3 0.1 
1.8 0.4 0.2 
1.8 0.5 0.3 
1.8 0.6 0.4 
1.8 0.7 0.4 
1.8 0.8 0.5 
1.8 0.9 0.5 

2.8 0.1 0.3 
2.8 0.2 0.4 
2.8 0.3 0.5
2.8 0.4 0.5
2.8 0.5 0.6
2.8 0.6 0.6
2.8 0.7 0.6
2.8 0.8 0.7
2.8 0.9 0.7

#

Upvotes: 0

Views: 2178

Answers (1)

maij
maij

Reputation: 4218

If you know how to plot a data file on a pm3d map, then you can use the table command to plot the function into a data file:

set table "temp_f.dat"
set samples 1000
fx(x) = (2*x-1)**2+1.8
plot fx(x)
unset table

set pm3d map explicit interpolate 10,10
set xrange [0.1:0.9]
set yrange [0.8:2.8]
splot "s.data" u 2:1:3, "temp_f.dat" u 1:2:(0) notitle with lines lw 2 lc 0

This is the result:

pm3d with function on top

Upvotes: 0

Related Questions