如何绘制显示其密度的(x,y,z)点

use*_*416 7 3d gnuplot density-plot

我的数据文件是一组围绕轴原点的(x,y,z)点.它们代表一种措施失败的点.这些要点在此链接中.

Gnuplot可以绘制它们,

set encoding iso_8859_1
set term postscript eps enhanced color size 4.7in,4in
set xlabel "X"
set ylabel "Y"
set zlabel "Z"
set output "test_gp.eps"
set style line 1 lc rgb '#0060ad' pt 7 ps 0.5 lt 1 lw 0.5 # --- blue
set style fill  transparent solid 0.15 noborder
splot "data.dat" u 1:2:3 w p ls 1 title "P_{error}"
Run Code Online (Sandbox Code Playgroud)

由此产生的情节

在此输入图像描述

问题是该图未显示更可能发生错误的位置.如果可能的话,我想展示点密度的变化.

我不知道是否可以改变点的颜色或给它们透明度,并尝试用最密集的点来表示位置.

如果3D点的密度的表示是不可能的,另一种方式可以是,使点的投影密度在三个平面(X = 0,Y,Z),(X,Y = 0,Z),( X,Y,Z = 0).

问候

编辑:

我可以用不同的颜色绘制我的实验的success(0)和error(1)点位置.此链接中的文件包含第4列,其中包含所有数据样本(0和1).

这个splot数字

splot "data_all.dat" u 1:2:3:4 w points ls 1 palette title "P_{error}"
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

但这个数字没有显示点的密度.例如,在Mathematica中,这些数据样本的密度图是

在此输入图像描述

我怎么能得到密度图Gnuplot?很可能Mathematica正在对中间点进行插值并给出0到1之间的值,但我不知道如何用Gnuplot实现它.

the*_*ozh 6

@ user1993416,我想你可以用gnuplot做点什么.您可能需要使用参数Delta.用我8岁的电脑1000点需要约.2分钟.

以下代码:

### 3D density plot
reset session
set term wxt

N = 1000      # number of datapoints
Delta = 2    # half boxwidth

TimeStart = time(0.0)
# create dummy some dummy data
set samples N
set table $Data
    plot '+' u (invnorm(rand(0))):(invnorm(rand(0))):(invnorm(rand(0))) with table
unset table

# put the datafile/dataset into arrays
stats $Data nooutput
RowCount = STATS_records
array ColX[RowCount]
array ColY[RowCount]
array ColZ[RowCount]
array ColC[RowCount]
do for [i=1:RowCount] {
set table $Dummy
    plot $Data u (ColX[$0+1]=$1,0):(ColY[$0+1]=$2,0):(ColZ[$0+1]=$3,0) with table
unset table
}

# look at each datapoint and its sourrounding
do for [i=1:RowCount] {
    print sprintf("Datapoint %g of %g",i,RowCount)
    x0 = ColX[i]
    y0 = ColY[i]
    z0 = ColZ[i]
    # count the datapoints with distances <Delta around the datapoint of interest
    set table $Occurrences
        plot $Data u ((abs(x0-$1)<Delta) & (abs(y0-$2)<Delta) & (abs(z0-$3)<Delta) ? 1 : 0):(1) smooth frequency
    unset table
    # extract the number from $Occurrences which will be used to color the datapoint
    set table $Dummmy
        plot $Occurrences u (c0=$2,0):($0) every ::1::1 with table
    unset table
    ColC[i] = c0
}

# put the arrays into a dataset again
set print $Data
do for [i=1:RowCount] {
    print sprintf("%g\t%g\t%g\t%g",ColX[i],ColY[i],ColZ[i],ColC[i])
}
set print

TimeEnd = time(0.0)
print sprintf("Duration: %.3f sec",TimeEnd-TimeStart)

set palette rgb 33,13,10
splot $Data u 1:2:3:4 w p ps 1 pt 7 lc palette z notitle

set terminal gif animate delay 30
set output "Density.gif"
Amin = 40
Amax = 60
AFrames = 25
do for [i=0:AFrames] {
    print sprintf("Frame %g, Angle: %.1f", i, sin(2*pi*i/AFrames)*(Amax-Amin)+Amin)
    set view 45,(sin(2*pi*i/AFrames)*(Amax-Amin)+Amin)
    replot
}
set output
Run Code Online (Sandbox Code Playgroud)

应该导致:

在此输入图像描述