如何使用gnuplot绘制密度图

如何使用gnuplot绘制密度图,gnuplot,density-plot,Gnuplot,Density Plot,对于分段函数 f(x,y) = x < 0 ? 0 : 0 <= x && x < 1 && x*y < 1 ? x : 1 我知道这是不正确的 编辑:之前,在定义分段函数时,我错误地编写了xy

对于分段函数

f(x,y) = x < 0 ? 0 : 0 <= x && x < 1 && x*y < 1 ? x : 1
我知道这是不正确的

编辑:之前,在定义分段函数时,我错误地编写了
xy<1
,而不是
x*y<1
。我已经更正了。

在你的
f(x,y)
中,
xy
应该是
x*y
。检查以下各项。使用采样,即
set samples
set isosamples
以获得更高或更低的分辨率。此外,请检查
help pm3d
help set调色板

代码:

### plot piecewise function as a map
reset session

set size ratio 0.5
f(x,y) = x < 0 ? 0 : 0 <= x && x < 1 && x*y < 1 ? x : 1

set samples 400
set isosamples 200
set palette defined (0 '#26548a', 0.5 '#e59e4a', 1 '#fff2bf')
set view map

set xlabel "d"
set xrange [-2:2]
set xtics 1
set ylabel "b"
set yrange [0:2]

splot f(x,y) w pm3d
### end of code
###将分段函数绘制为映射
重置会话
设定尺寸比0.5
f(x,y)=x<0?0 : 0
set hidden3d
set dgrid3d 50,50 qnorm 2
set view map
splot f(x,y) 
### plot piecewise function as a map
reset session

set size ratio 0.5
f(x,y) = x < 0 ? 0 : 0 <= x && x < 1 && x*y < 1 ? x : 1

set samples 400
set isosamples 200
set palette defined (0 '#26548a', 0.5 '#e59e4a', 1 '#fff2bf')
set view map

set xlabel "d"
set xrange [-2:2]
set xtics 1
set ylabel "b"
set yrange [0:2]

splot f(x,y) w pm3d
### end of code