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

查看:130
本文介绍了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'的第四列读取)?像这样:

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中也具有带有圆圈的绘图样式 ,之前它仅限于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天全站免登陆