使用 gnuplot 在球体上绘制点
Plotting points on a sphere with gnuplot
我有一个数据文件,其中包含一组仅限于球体表面的点 (x,y,z)。
我想绘制它们,但我不希望所有的点都出现在图上,
只有那些在 3d 中可见的。
我的想法是画一个实心球体,以便从后面隐藏点。
我尝试按照 回答,但首先,如果我在 pdf 中绘图,我会得到这个。
其次,我想用 pt7 或一些小的东西将点绘制为点,但在 gnuplot qt 查看器中
仍然有一个白色的线框,如图所示:
我想实现类似的东西:
如何删除此线框?如果有人知道使用 pgfplots、tikz 或其他软件执行此操作的更简单方法,它也能满足我的需求。
可能的解决方案如下:
- 为半径为 R 的原型球体生成 xyz 数据
- 用不可见线 (
lt -2
) 和 set hidden3d
绘制球体数据
- 绘制您的 xyz 点,此处作为演示
world.dat
。
也许我想的太复杂了,有更简单的解决方案。我使用动画版本 "illustrate" 隐藏点。我希望你能根据你的需要调整代码。
代码:
### points on sphere partly hidden
reset session
set view equal xyz
set xyplane relative 0
R = 1
unset tics
unset border
# sphere prototype data
set parametric
set isosamples 24
set samples 24
set urange [0:2*pi]
set vrange [-pi/2:pi/2]
set table $Sphere
splot R*cos(u)*cos(v), R*sin(u)*cos(v), R*sin(v)
unset table
unset parametric
# convert "world.dat" data into x,y,z coordinates
# file can be found in directory gnuplot/demo
set angle degrees
set table $World
plot "world.dat" u (R*cos()*cos()):(R*sin()*cos()):(R*sin()) w table
unset table
set hidden3d
set term gif animate size 400,400 delay 20 optimize
set output "tbWorldInDots.gif"
N = 36
do for [i=N:1:-1] {
set view 90,360./N*i,1.8
splot \
$Sphere u 1:2:3 w l lt -2 notitle , \
$World u 1:2:3 w p pt 7 ps 0.5 lc rgb "black" notitle, \
}
set output
### end of code
结果:
我有一个数据文件,其中包含一组仅限于球体表面的点 (x,y,z)。
我想绘制它们,但我不希望所有的点都出现在图上,
只有那些在 3d 中可见的。
我的想法是画一个实心球体,以便从后面隐藏点。
我尝试按照
其次,我想用 pt7 或一些小的东西将点绘制为点,但在 gnuplot qt 查看器中 仍然有一个白色的线框,如图所示:
我想实现类似的东西:
如何删除此线框?如果有人知道使用 pgfplots、tikz 或其他软件执行此操作的更简单方法,它也能满足我的需求。
可能的解决方案如下:
- 为半径为 R 的原型球体生成 xyz 数据
- 用不可见线 (
lt -2
) 和set hidden3d
绘制球体数据
- 绘制您的 xyz 点,此处作为演示
world.dat
。
也许我想的太复杂了,有更简单的解决方案。我使用动画版本 "illustrate" 隐藏点。我希望你能根据你的需要调整代码。
代码:
### points on sphere partly hidden
reset session
set view equal xyz
set xyplane relative 0
R = 1
unset tics
unset border
# sphere prototype data
set parametric
set isosamples 24
set samples 24
set urange [0:2*pi]
set vrange [-pi/2:pi/2]
set table $Sphere
splot R*cos(u)*cos(v), R*sin(u)*cos(v), R*sin(v)
unset table
unset parametric
# convert "world.dat" data into x,y,z coordinates
# file can be found in directory gnuplot/demo
set angle degrees
set table $World
plot "world.dat" u (R*cos()*cos()):(R*sin()*cos()):(R*sin()) w table
unset table
set hidden3d
set term gif animate size 400,400 delay 20 optimize
set output "tbWorldInDots.gif"
N = 36
do for [i=N:1:-1] {
set view 90,360./N*i,1.8
splot \
$Sphere u 1:2:3 w l lt -2 notitle , \
$World u 1:2:3 w p pt 7 ps 0.5 lc rgb "black" notitle, \
}
set output
### end of code
结果: