How to plot (x,y,z) points showing their density

后端 未结 1 1491
执念已碎
执念已碎 2021-01-05 00:43

My data file is a set of (x,y,z) points located around the axis origin. They represent points where a kind of measure has failed. These points are in this link.

Gnup

1条回答
  •  伪装坚强ぢ
    2021-01-05 01:20

    @user1993416, I guess you can do something with gnuplot. You might need to play with the parameter Delta. With my 8 year old computer 1000 points need approx. 2 minutes.

    The followig code:

    ### 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 

    should result in:

    0 讨论(0)
提交回复
热议问题