gnuplot:如何用splot和pm3d保持恒定的颜色?

问题描述 投票:2回答:1

基本上,我想通过参数化splot绘制彩色球体(下图,顶部)。但是,我找不到让它们颜色均匀但每个球体颜色不同的方法。

我发现这篇文章(qazxsw poi)教我通过首先将球体绘制到数据块然后绘制移位的数据块(图像下方,中间)来实现它。

现在,我想添加一些行。但随后球体的颜色意外地改变了它们的颜色(图像在下方,底部)。为什么?怎么避免?如何保留原来的颜色?

我的代码:

Gnuplot, pm3d and surfaces

结果:

### connected 3D-spheres with splot and pm3d reset session set obj 1 rect from screen 0,0,0 to screen 1,1,0 behind set obj 1 rect fc rgb "black" fs solid 1.0 set view equal xyz set view 45,45 unset border unset tics unset colorbox set style fill solid 1.0 noborder set pm3d depthorder noborder set pm3d lighting specular 0.5 set isosamples 50,50 set parametric set urange [-pi/2:pi/2] set vrange [0:2*pi] Radius = 1 set table $Sphere splot Radius*cos(u)*cos(v), Radius*cos(u)*sin(v), Radius*sin(u) unset table unset parametric $Pos <<EOD 0 0 0 4 0 0 4 4 0 0 4 0 EOD $Bonds <<EOD 0 0 0 4 0 0 4 0 0 4 4 0 4 4 0 0 4 0 0 4 0 0 0 0 EOD PosX(i) = word($Pos[i],1) PosY(i) = word($Pos[i],2) PosZ(i) = word($Pos[i],3) set palette defined (1 'red', 2 'green', 3 'blue', 4 'yellow') set multiplot layout 3,1 set parametric splot for [i=1:4] Radius*cos(u)*cos(v)+PosX(i), Radius*cos(u)*sin(v)+PosY(i), \ Radius*sin(u)+PosZ(i) with pm3d not unset parametric unset obj 1 splot \ for [i=1:4] $Sphere u ($1+PosX(i)):($2+PosY(i)):($3+PosZ(i)):(i) with pm3d not splot \ for [i=1:4] $Sphere u ($1+PosX(i)):($2+PosY(i)):($3+PosZ(i)):(i) with pm3d not,\ $Bonds u 1:2:3 w l lw 4 lc rgb "grey" not unset multiplot ### end of code

colors 3d gnuplot surface
1个回答
1
投票

这是第二个解决方案,不涉及设置调色板。请注意,这需要来自gnuplot(版本5.3)的开发分支的功能。它将出现在未来的稳定版本中,但尚未在5.2.6版本中出现。

[上面的预赛,然后是]

enter image description here

set palette defined (1 'red', 2 'green', 3 'blue', 4 'yellow') set style line 1 lc 'red' set style line 2 lc 'green' set style line 3 lc 'blue' set style line 4 lc 'yellow' set multiplot layout 1,3 set parametric splot for [i=1:4] Radius*cos(u)*cos(v)+PosX(i), Radius*cos(u)*sin(v)+PosY(i), \ Radius*sin(u)+PosZ(i) with pm3d not unset parametric unset obj 1 splot \ for [i=1:4] $Sphere u ($1+PosX(i)):($2+PosY(i)):($3+PosZ(i)):(i) with pm3d not splot \ for [i=1:4] $Sphere u ($1+PosX(i)):($2+PosY(i)):($3+PosZ(i)) with pm3d fc ls i not,\ $Bonds u 1:2:3 w l lw 4 lc rgb "grey" not unset multiplot 也会工作(线型而不是线型)

with pm3d fc lt i

© www.soinside.com 2019 - 2024. All rights reserved.