0

I would like to make a 3D plot with gnuplot using the interface.txt file (File). Knowing that I have a y-axis rotation invariance. This figure represents a 2D section (plot 'interface.txt' u 2:1) 2D section

Here's what I'd like to have with gnuplot but I don't know how to plot it. I would like to get this picture but for theta = [0:2*pi]. enter image description here I tried this code but for now i don't know how to plot it

reset
set angles degrees
set mapping cylindrical

splot for [t=1:360:2] 'interface.txt' u t:1:(sqrt($2**2+$1**2))

If you have any idea ? Thanks you !

Suntory
  • 305
  • 2
  • 15

2 Answers2

1

I'm not sure whether the example below satisfies your expectations. Since your original curve is not closed, this is not a body but a surface. For pm3d to do the "connections" between the rotated curves, I guess you have to have add a single empty line between the rotated curves. You can get this with the "trick" of plotting a dummy array with one element: plot A u ("") w table. I hope that there are better solutions.

Code:

### rotation of a curve
reset session

set angle degrees
set table $Rotation
    array A[1]   # dummy array for plotting a single empty line
    do for [i=0:360:15] {
        plot "interface.txt" u ($2*cos(i)):($2*sin(i)):1 w table
        plot A u ("") w table
    }
unset table

set pm3d hidden3d depthorder

# set view equal xyz   # uncomment to have equal x,y,z scales
set view 30,50,1.3     # scale 1.3 to reduce white space around

splot $Rotation u 1:2:3 w pm3d lt -2 notitle
### end of code

Result:

enter image description here

theozh
  • 22,244
  • 5
  • 28
  • 72
  • Thanks a lot ! almost perfect, now we just have to close the two surfaces to get one body – Suntory May 13 '20 at 19:35
  • Do you know if it's possible to add "set contour base with isosample and pm3d map" on the xy plane ? while keeping my solid 3D – Suntory May 18 '20 at 15:49
0

Thanks you, it is almost perfect. Now it try to close my 2 surfaces. enter image description here

So we need to link the edge of the curve to get one body. For that I use stats :

enter image description here

And then the final code :

### rotation of a curve
reset session

set print $interface
stats 'interface.txt' nooutput
print sprintf("%g %g", STATS_max_y, STATS_pos_max_y)
print sprintf("%g %g", STATS_max_y, -STATS_pos_max_y)
set angle degrees
set table $Rotation
    array A[1]   # dummy array for plotting a single empty line
    do for [i=0:360:10] {
        plot "interface.txt" u ($2*cos(i)):($2*sin(i)):1 w table
    plot "interface.txt" u ($2*cos(i)):($2*sin(i)):(-$1) w table
    plot $interface u ($1*cos(i)):($1*sin(i)):2 w table
        plot A u ("") w table
    }
unset table

unset key
set border
set style fill solid 1.00 border -1
set view 62, 8, 1.245, 1.0

set ticslevel 0
set pm3d depthorder interpolate 4,4 lighting specular 0.6 at s

# set view equal xyz   # uncomment to have equal x,y,z scales

splot $Rotation u 1:2:3 w pm3d lt -2 notitle
### end of code

enter image description here

Suntory
  • 305
  • 2
  • 15
  • 1
    glad that it worked. Then this should be the accepted answer, my answer was just helpful ;-). Keep in mind when creating a datablock with `set print $interface`, when your done creating the datablock use `set print` or `unset print` to stop printing everything to this datablock.In case you want to print something to the gnuplot console window. – theozh May 14 '20 at 08:01