gnuplot:如何绘制具有不同直径的 3D 均匀球体? [英] gnuplot: How to plot homogeneous spheres in 3D with different diameters?

查看:38
本文介绍了gnuplot:如何绘制具有不同直径的 3D 均匀球体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 gnuplot 对大量不同直径的球体进行 3D 表示,其信息位于名为 'data.dat' 的文件中.如果我这样做:

I want to make a 3D representation of a large number of spheres of different diameter using gnuplot and whose information are in a file called 'data.dat'. If I do:

splot 'data.dat' u 1:2:3 w p lt 7 

我得到了一系列小尺寸的同色点.如何使用 splot 命令添加球体的真实大小(从文件 'data.dat' 的第 4 列读取)?类似的东西:

I get a series of points of small dimensions of a homogeneous color. How can I add the real size of the spheres (read from the 4th column of the file 'data.dat') using the splot command? Something like:

splot 'data.dat' u 1:2:3:4 ...

推荐答案

从 gnuplot 5.4 开始,我猜你在 3D 中也有 with circles 的绘图样式,以前,它仅限于 2D 绘图.

Since gnuplot 5.4, I guess you have the plotting style with circles also in 3D, before, it was limited to 2D plots.

如果您有较旧的 gnuplot 版本,您可以执行以下操作:

If you have an older gnuplot version you could do something like:

splot 'data.dat' u 1:2:3:4 w p pt 7 ps var notitle

这将绘制具有可变大小的点.但是,您要求真实"尺寸.您可以通过使用某些因素缩放第 4 列来解决此问题.类似的东西:

This will plot points with variable size. However, you asked for "real" size. You might workaround this with scaling the 4th column with some factor. Something like:

Factor = 0.123
splot 'data.dat' u 1:2:3:($4*Factor) w p pt 7 ps var notitle

以下仅适用于 gnuplot >=5.4:

The following works only for gnuplot >=5.4:

代码:

### plot with circles in 3D (only for gnuplot >=5.4)
reset session

# create some test data
set print $Data
    do for [i=1:100] {
        print sprintf("%g %g %g %g %g", rand(0), rand(0), rand(0), rand(0)*0.02+0.02, int(rand(0)*0xffffff))
    }
set print

set view 60,30,1.25
set view equal xyz
set xyplane at 0
set tics 0.2
set style fill solid 0.5

splot $Data u 1:2:3:4:5 w circles lc rgb var notitle
### end of code

结果:

这篇关于gnuplot:如何绘制具有不同直径的 3D 均匀球体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆