3 # This program plots several 2D and 3D polyhedra on the same figure,
4 # illustrating some of the possible plot options.
6 import matplotlib
.pyplot
as plt
8 from matplotlib
import pylab
9 from mpl_toolkits
.mplot3d
import Axes3D
11 from linpy
import Ge
, Le
, symbols
14 x
, y
, z
= symbols('x y z')
16 diam
= Ge(y
, x
- 1) & Le(y
, x
+ 1) & Ge(y
, -x
- 1) & Le(y
, -x
+ 1)
19 Le(0, x
, 3) & Le(0, y
, 3) & Le(0, z
, 3) &
20 Le(z
- 2, x
, z
+ 2) & Le(1 - z
, x
, 5 - z
) &
21 Le(z
- 2, y
, z
+ 2) & Le(1 - z
, y
, 5 - z
) &
22 Le(y
- 2, x
, y
+ 2) & Le(1 - y
, x
, 5 - y
))
25 Le(x
+ y
+ z
, 7) & Ge(-2, -x
- y
- z
) &
26 Le(-1, x
+ y
- z
, 4) & Le(-1, x
- y
+ z
, 4) & Le(-1, -x
+ y
+ z
, 4))
29 Le(0, x
, 5) & Le(0, y
, 5) & Le(0, z
, 5) &
30 Le(x
- 4, y
, x
+ 4) & Le(-x
+ 1, y
, -x
+ 9) &
31 Le(y
- 4, z
, y
+ 4) & Le(-y
+ 1, z
, -y
+ 9) &
32 Le(z
- 4, x
, z
+ 4) & Le(-z
+ 1, x
, -z
+ 9) &
33 Le(3, x
+ y
+ z
, 12) & Le(-2, x
- y
+ z
, 7) &
34 Le(-2, -x
+ y
+ z
, 7) & Le(-2, x
+ y
- z
, 7))
37 if __name__
== '__main__':
39 fig
= plt
.figure(facecolor
='white')
41 diam_plot
= fig
.add_subplot(2, 2, 1, aspect
='equal')
42 diam_plot
.set_title('Diamond')
43 diam
.plot(diam_plot
, fill
=True, edgecolor
='red', facecolor
='yellow')
45 cham_plot
= fig
.add_subplot(2, 2, 2, projection
='3d', aspect
='equal')
46 cham_plot
.set_title('Chamfered cube')
47 cham
.plot(cham_plot
, facecolors
=(1, 0, 0, 0.75))
49 rhom_plot
= fig
.add_subplot(2, 2, 3, projection
='3d', aspect
='equal')
50 rhom_plot
.set_title('Rhombicuboctahedron')
51 rhom
.plot(rhom_plot
, facecolors
=(0, 1, 0, 0.75))
53 cubo_plot
= fig
.add_subplot(2, 2, 4, projection
='3d', aspect
='equal')
54 cubo_plot
.set_title('Truncated cuboctahedron')
55 cubo
.plot(cubo_plot
, facecolors
=(0, 0, 1, 0.75))