lbenedetto
lbenedetto

Reputation: 2114

How do I draw a cube/rectangle with GnuPlot?

I am trying to draw a series of cubes like so:

enter image description here

What is the simplest way to define a cube in GnuPlot?

Upvotes: 2

Views: 1334

Answers (1)

lbenedetto
lbenedetto

Reputation: 2114

According to the GnuPlot docs, the correct way to define a cube is to define 4 sets of 5 3D points.

However, a cube can also be defined with 2 sets of 5 3D points. The first set will define the top of the box. So if the top 4 points on the cube were

AB
CD

And the bottom 4 points on the cube are

EF
GH

The gnuplot would be

A
B
D
C
A

E
F
H
G
E

Each set of 5 points defines the 4 lines gnuplot needs to draw to make the top and bottom plane of the cube, respectively. Gnuplot will automatically connect the two planes.

Note that the blank line between the two sets is very important.

Between each cube that you draw, there should be two blank lines. If you don't have the two blank lines, Gnuplot will connect your two cubes with lines.

Upvotes: 2

Related Questions