【问题标题】:plot cylindrical coordinate using an x y file in gnuplot在 gnuplot 中使用 x y 文件绘制圆柱坐标
【发布时间】:2020-05-11 12:44:02
【问题描述】:

我想使用 interface.txt 文件 (File) 使用 gnuplot 制作 3D 绘图。 知道我有一个 y 轴旋转不变性。 此图代表一个 2D 截面(plot 'interface.txt' u 2:1)

这是我想用 gnuplot 做的,但我不知道如何绘制它。 我想得到这张照片,但对于 theta = [0:2*pi]。 我试过这段代码,但现在我不知道如何绘制它

reset
set angles degrees
set mapping cylindrical

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

如果你有任何想法? 谢谢你!

【问题讨论】:

  • 您的数据是一条开放曲线。它应该以某种方式关闭吗?如果是,如何?
  • 是的,我认为我们可以使用 pm3d 关闭曲线。也许使用特殊文件名和我的数据文件,我们可以绘制这个......

标签: 3d gnuplot cylindrical


【解决方案1】:

我不确定下面的示例是否满足您的期望。 由于您的原始曲线不是闭合的,因此这不是一个实体而是一个曲面。 对于pm3d 在旋转曲线之间进行“连接”,我想您必须在旋转曲线之间添加一条空线。您可以通过绘制具有一个元素的虚拟数组的“技巧”来实现这一点:plot A u ("") w table。希望有更好的解决方案。

代码:

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

结果:

【讨论】:

  • 非常感谢!几乎完美,现在我们只需要关闭两个表面就可以得到一个实体
  • 您知道是否可以在 xy 平面上添加“使用 isosample 和 pm3d 地图设置轮廓基础”?同时保持我的立体 3D
【解决方案2】:

谢谢你,它几乎是完美的。 现在它尝试关闭我的 2 个表面。

所以我们需要连接曲线的边缘来得到一个实体。 为此,我使用 stats :

然后是最终代码:

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

【讨论】:

  • 很高兴它成功了。那么这应该是公认的答案,我的回答很有帮助;-)。请记住,使用set print $interface 创建数据块时,当您完成创建数据块时,使用set printunset print 停止将所有内容打印到此数据块。如果您想在 gnuplot 控制台窗口打印某些内容。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-23
相关资源
最近更新 更多