如何在pm3d地图上绘制数学公式给出的新线

时间:2017-05-11 13:49:51

标签: gnuplot

ENV

gnuplot 5.0 patchlevel 1

How to plot discrete points on top of pm3d map in gnuplot?, 代码和他的迷你数据

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

Draw a line in a pm3d mapHow to mark some points on 2D heat map in gnuplot?是类似的解决方案。但他们使用数据文件而不是数学公式。

我还尝试了How to overlay dots/points scatter plot onto a pm3d map/surfaceHow to overlay contour plot over pm3d map/surfaceHow do I plot lines (not grids) using splot?

  

尝试一下unset surface,set surface explicit,plot ... nosurface的组合。   。   这些似乎是3D协调的解决方案。

我仍然没有得到预期的结果。

我错过了什么吗?提前谢谢。

我的代码如下:

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

我的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

#

1 个答案:

答案 0 :(得分:0)

如果您知道如何在pm3d地图上绘制数据文件,那么您可以使用table命令将该函数绘制到数据文件中:

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

结果如下:

pm3d with function on top