3d2dgnuplotprojection

Plotting 3d data and its projections - gnuplot


I am trying to plot the projections of a 3D data set on its corresponding xy, zy, zx planes, but I have found no information about that. It seems it is a forbidden topic or just impossible to do. I attach a picture as example enter image description here. I would like to let a data file but there is no way to upload anything here. Therefore, I paste it below if you want to try. First col. is frequency, 2nd is real part and 3rd imaginary part; I recommend plotting with 1:2:3.

1.00E+05    173.026357  31.03390887
6.31E+04    180.723259  23.8603962
3.98E+04    184.1098959 19.11910457
2.51E+04    187.4965328 16.50215789
1.59E+04    190.8831696 15.27373233
1.00E+04    193.5001163 15.48616683
6.31E+03    197.1946293 16.81003397
3.98E+03    200.7352042 19.28843642
2.51E+03    205.3533454 23.0599184
1.59E+03    211.2029909 28.41696219
1.00E+03    217.9762647 35.7598067
6.31E+02    226.1349808 45.7503855
3.98E+02    236.6027675 59.32772063
2.51E+02    250.3032531 77.43083413
1.59E+02    268.6218798 101.3681994
1.00E+02    292.0204619 132.7715595
6.31E+01    321.8844417 173.3342331
3.98E+01    362.5240843 226.904671
2.51E+01    415.6327081 297.2543553
1.59E+01    484.750888  388.8474891
1.00E+01    531.7019902 414.2472657
6.31E+00    632.0695923 564.1829167
3.98E+00    779.5422347 759.9921036
2.51E+00    988.7440311 1025.381285
1.59E+00    1271.836087 1397.757403
1.00E+00    1642.518887 1830.323296
6.31E-01    2144.356898 2376.803338
3.98E-01    2786.278524 3061.827616
2.51E-01    3628.319603 3916.183738
1.59E-01    4759.764198 5027.616387
1.00E-01    6297.605217 6296.065837
6.31E-02    8383.46566  7619.932981
3.98E-02    11028.12119 8786.783325
2.51E-02    14096.10633 9558.012905
1.59E-02    17456.57374 9912.070397
1.00E-02    20673.87878 9807.39253
6.31E-03    23537.12632 9387.141681
3.98E-03    24784.02444 7975.529854
2.51E-03    25461.35182 6999.56268
1.59E-03    27339.39591 6593.166254
1.00E-03    28909.56392 5798.845968

I couldn't try anything because I didn't even find anything to start with. This is something very common in literature of all branch of sciences, I don't understand why it is not a very clear or addressed topic in gnuplot...

It would be nice if someone find a way to plot the aforementioned projections TOGETHER WITH the 3D data set, as in the image attached (in which data are points, fit is the green line, and the desired projections are the blue lines). Also, it would be great if someone explains how to get that "shadow" under de green line.

Please, do note that the 3D object is a curve, not a surface. For surfaces there are solutions for what I ask, but not for this particular case.

Also, if there is a way to attach txt files, please, do let me know. Fortunately, the data set was small, but it would be horrible to paste here a data set with more than 1000 rows...

THANKS YOU


Solution

  • From your description I guess you are looking for the following...

    Your data set it 3D-data, so you need to plot it with splot (in gnuplot console check help splot). Something like: splot FILE u 1:2:3 which is x:y:z. If you want to plot a projection you take the same data but set one of the coordinates to a fixed value, either the minimum of maximum depending on which surface you want to project it. This means for example splot FILE u (xmin):2:3. Mind the parentheses around the fixed value xmin.

    If you want to plot fitted data as well you need a function to fit the data.

    The tic labels and axis labels are not so nice in splot, I don't know of a good way to make them nicer.

    Data: SO78531368.dat

    1.00E+05    173.026357  31.03390887
    6.31E+04    180.723259  23.8603962
    3.98E+04    184.1098959 19.11910457
    2.51E+04    187.4965328 16.50215789
    1.59E+04    190.8831696 15.27373233
    1.00E+04    193.5001163 15.48616683
    6.31E+03    197.1946293 16.81003397
    3.98E+03    200.7352042 19.28843642
    2.51E+03    205.3533454 23.0599184
    1.59E+03    211.2029909 28.41696219
    1.00E+03    217.9762647 35.7598067
    6.31E+02    226.1349808 45.7503855
    3.98E+02    236.6027675 59.32772063
    2.51E+02    250.3032531 77.43083413
    1.59E+02    268.6218798 101.3681994
    1.00E+02    292.0204619 132.7715595
    6.31E+01    321.8844417 173.3342331
    3.98E+01    362.5240843 226.904671
    2.51E+01    415.6327081 297.2543553
    1.59E+01    484.750888  388.8474891
    1.00E+01    531.7019902 414.2472657
    6.31E+00    632.0695923 564.1829167
    3.98E+00    779.5422347 759.9921036
    2.51E+00    988.7440311 1025.381285
    1.59E+00    1271.836087 1397.757403
    1.00E+00    1642.518887 1830.323296
    6.31E-01    2144.356898 2376.803338
    3.98E-01    2786.278524 3061.827616
    2.51E-01    3628.319603 3916.183738
    1.59E-01    4759.764198 5027.616387
    1.00E-01    6297.605217 6296.065837
    6.31E-02    8383.46566  7619.932981
    3.98E-02    11028.12119 8786.783325
    2.51E-02    14096.10633 9558.012905
    1.59E-02    17456.57374 9912.070397
    1.00E-02    20673.87878 9807.39253
    6.31E-03    23537.12632 9387.141681
    3.98E-03    24784.02444 7975.529854
    2.51E-03    25461.35182 6999.56268
    1.59E-03    27339.39591 6593.166254
    1.00E-03    28909.56392 5798.845968
    

    Script:

    ### plotting 3D data and 2D projections
    reset session
    
    FILE = "SO78531368.dat"
    
    set xlabel "Frequency / Hz" rotate parallel
    set xrange[xmin=5e-4 : xmax=5e5]
    set xtics out scale 2,1
    set ylabel "Real part" rotate parallel
    set yrange[ymin=-1000 : ymax=30000]
    set format y "       %g"
    set zlabel "Imaginary part" rotate by 90 offset -1,0
    set zrange[zmin=0 : zmax=11000]
    set ztics 1000
    set border 1+2+4+8+16+32+64+256+512
    set xyplane relative zmin
    set logscale x
    set grid x,y,z vertical
    set key noautotitle
    set view 60,30
    
    splot FILE u 1:2:3 w l lw 3 lc "red", \
            '' u 1:2:3 w impulses lc "magenta", \
            '' u 1:2:(zmin) w l lc "magenta", \
            '' u (xmin):2:3 w lp pt 7 ps 0.5 lc "web-green", \
            '' u 1:(ymax):3 w lp pt 7 ps 0.5 lc "web-blue"
    ### end of script
    

    Result:

    enter image description here