1

Hello fellow stackers,

So I am a gnuplot afficcionado and I keep trying to use gnuplot to draw all sorts of things (including molecules) using it. These days I decided that it would be awesome if I could draw polyhedran in it with this beautiful thining-edge occlusion effect that we see in the interactive javascript polyhedral images here. See how the backside of the polyhedron is drawn differently from the front side and how they change dynamically as you rotate the solid? How can I do that in gnuplot?

urquiza
  • 307
  • 2
  • 11

1 Answers1

2

I agree that is a really nice representation. Gnuplot cannot currently do the equivalent of "draw the inside edges using thinner lines", but the combination of partial transparency and using the background color as the fill color for the faces creates almost the same effect.

# Generation of polyhedral vertices and faces not shown.
# Each face is an object of type polygon, e.g.
#     set object 1 polygon from ... to ... to ...

# make all the faces semi-transparent
set for [i=1:20] object i fillstyle transparent solid 0.6 fillcolor bgnd border lw 2
# use pm3d depthorder sorting to render the objects
# NB: gnuplot version 5.3 required
set for [i=1:20] object i polygon depthorder

set xrange [-2:2]; set yrange [-2:2]; set zrange [-2:2]
set view equal xyz
set view 30,30,1.5
unset border
unset tics
unset key
unset label
splot NaN

Results shown below for a cube and for an icosahedron. You can rotate them interactively as with any other splot.

cubeicosahedron

Ethan
  • 13,715
  • 2
  • 12
  • 21
  • This gets the job done. But I am curious as to how can I generate the polygon objects from data in a file. Would that be too hard? – urquiza Oct 07 '19 at 09:30
  • @urquiza Here is you in the future. It is a tiny bit hard, but I have figured it out. I'll let you know. – urquiza Aug 08 '23 at 11:49