首页 > 解决方案 > 在 Gnuplot 中是否可以在曲面图下的 xyplane 上绘制 2D 图?

问题描述

我正在尝试创建类似于这些图的内容:

目标图描绘了两个多元高斯分布的联合 pdf 和它们之间的贝叶斯决策边界。

我有表面图,现在我想把它放在下面分别绘制:

描绘关节的曲面图 pdf 二维散点图

我尝试将 2D 图像绘制为曲面图中的二进制图,但每个像素都被解释为坐标系中的一个整体,这是不正确的,它最终会复制坐标轴和绘图标题等。好吧,gnuplot 的 xyplane 不一定位于 z=0,因此仅使用 splot 通常使用 z 值为 0 进行绘图也不能满足我的要求。

到目前为止,这些是我的绘图文件:

二维散点图:

set terminal png enhanced size 8000, 4800 truecolor font "arial,60"
set encoding utf8
set output outfile

set autoscale fix

set border lw 3
set style fill transparent solid 0.075 noborder
set style circle radius 0.03

set title plotTitle

plot sample1 u 1:2 w circles notitle,\
     sample2 u 1:2 w circles notitle,\
     $ContourTable w lines lw 6 lc rgb 'black' notitle,\
     keyentry w circles fill solid 1.0 noborder lc 1 title "ω_1",\
     keyentry w circles fill solid 1.0 noborder lc 2 title "ω_2"

曲面图:

set terminal png enhanced size 8000, 4800 truecolor font "arial,60"
set encoding utf8
set output outfile

set autoscale fix
set border lw 3
set title plotTitle
set isosamples 100
set pm3d at s explicit hidden3d
unset hidden3d
set palette model RGB define (1 "dark-violet", 2 "#009e73")

splot pdfFile u 1:2:3:4 w pm3d lc rgb "black"

标签: plotgnuplot

解决方案


也许是这样的?也许需要适应您的数据并进一步微调。

代码:

### surface plot with contour
reset session

GaussW3D(x,y,x0,y0,A,FWHM) = A * exp(-(x-x0)**2/(2*(FWHM/(2*sqrt(2*log(2))))**2)) *\
                                 exp(-(y-y0)**2/(2*(FWHM/(2*sqrt(2*log(2))))**2))
                                 
set samples 40
set isosamples 40

f(x,y) = GaussW3D(x,y,4,4,1,5) + GaussW3D(x,y,0,0,1.5,3)
set contour base
set cntrparam levels 10
set hidden3d
set xyplane at -2
set ztics 0.5

splot sample [-4:10][-7:10] '++' u 1:2:(f(x,y)) w l

### end of code

结果:

在此处输入图像描述


推荐阅读