gpt4 book ai didi

Gnuplot:散点图和密度

转载 作者:行者123 更新时间:2023-12-01 11:21:23 24 4
gpt4 key购买 nike

我有代表星团的 x 和 y 数据点。我想使用 Gnuplot 及其带有重叠点的散点函数来可视化密度。

我使用了以下命令:

 set style fill transparent solid 0.04 noborder
set style circle radius 0.01
plot "data.dat" u 1:2 with circles lc rgb "red"

结果:

enter image description here

但是我想要这样的东西

enter image description here

这在 Gnuplot 中可能吗?有任何想法吗?

最佳答案

可能比我之前的答案更好的方法如下。
在我 8 岁的电脑上,1000 分大约需要 2-3 分钟。你基本上可以对 3D 做同样的事情(见 https://stackoverflow.com/a/53744193/7295599)

编码:

### density color plot 2D
reset session

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

TimeStart = time(0.0)
# create some dummy datablock with some distribution
set table $Data
set samples N
plot '+' u (invnorm(rand(0))):(invnorm(rand(0))) w table
unset table
print sprintf("Data generated: %.3f sec",time(0.0)-TimeStart)
# end creating dummy data

TimeStart = time(0.0)
# put the datafile/dataset into arrays
stats $Data nooutput
RowCount = STATS_records
array ColX[RowCount]
array ColY[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) with table
unset table
}
print sprintf("Data put into arrays: %.3f sec",time(0.0)-TimeStart)


# 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]
# 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) ? 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",ColX[i],ColY[i],ColC[i])
}
set print
print sprintf("Duration: %.3f sec",time(0.0)-TimeStart)

set palette rgb 33,13,10
plot $Data u 1:2:3 w p ps 1 pt 7 lc palette z notitle
### end of code

将导致类似:

enter image description here

关于Gnuplot:散点图和密度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42368448/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com