Basically, I want to draw colored spheres via parametric splot
(image below, top). However, I couldn't find a way to make them uniform in color but each sphere with a different color.
I found this post (Gnuplot, pm3d and surfaces) which tought me to achieve it by plotting the spheres to a datablock first and then plot the shifted datablock (image below, middle).
Now, I want to add some lines. But then the colors of the spheres unexpectedly change their color (image below, bottom). Why? How to avoid? How can I keep the originally intended colors?
My code:
### 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
The result: