diam_plot = fig.add_subplot(2, 2, 1)
diam_plot.set_title('Diamond')
-diam_plot.set_xlim(-1, 1)
-diam_plot.set_ylim(-1, 1)
diam = Ge(y, x - 1) & Le(y, x + 1) & Ge(y, -x - 1) & Le(y, -x + 1)
diam.plot(diam_plot, fill=True, edgecolor='red', facecolor='yellow')
cham_plot = fig.add_subplot(2, 2, 2, projection='3d')
cham_plot.set_title('Chamfered cube')
-cham_plot.set_xlim(0, 3)
-cham_plot.set_ylim(0, 3)
-cham_plot.set_zlim(0, 3)
cham = Le(0, x) & Le(x, 3) & Le(0, y) & Le(y, 3) & Le(0, z) & Le(z, 3) & \
Le(z - 2, x) & Le(x, z + 2) & Le(1 - z, x) & Le(x, 5 - z) & \
Le(z - 2, y) & Le(y, z + 2) & Le(1 - z, y) & Le(y, 5 - z) & \
rhom_plot = fig.add_subplot(2, 2, 3, projection='3d')
rhom_plot.set_title('Rhombicuboctahedron')
-rhom_plot.set_xlim(0, 3)
-rhom_plot.set_ylim(0, 3)
-rhom_plot.set_zlim(0, 3)
rhom = cham & \
Le(x + y + z, 7) & Ge(-2, -x - y - z) & \
Le(-1, x + y - z) & Le(x + y - z, 4) & \
cubo_plot = fig.add_subplot(2, 2, 4, projection='3d')
cubo_plot.set_title('Truncated cuboctahedron')
-cubo_plot.set_xlim(0, 5)
-cubo_plot.set_ylim(0, 5)
-cubo_plot.set_zlim(0, 5)
cubo = Le(0, x) & Le(x, 5) & Le(0, y) & Le(y, 5) & Le(0, z) & Le(z, 5) & \
Le(x -4, y) & Le(y, x + 4) & Le(-x + 1, y) & Le(y, -x + 9) & \
Le(y -4, z) & Le(z, y + 4) & Le(-y + 1, z) & Le(z, -y + 9) & \
return faces
def _plot_2d(self, plot=None, **kwargs):
- from matplotlib import pylab
import matplotlib.pyplot as plt
- from matplotlib.axes import Axes
from matplotlib.patches import Polygon
vertices = self._sort_polygon_2d(self.vertices())
xys = [tuple(vertex.values()) for vertex in vertices]
if plot is None:
fig = plt.figure()
plot = fig.add_subplot(1, 1, 1)
- xs, ys = zip(*xys)
- plot.set_xlim(float(min(xs)), float(max(xs)))
- plot.set_ylim(float(min(ys)), float(max(ys)))
+ xmin, xmax = plot.get_xlim()
+ ymin, ymax = plot.get_xlim()
+ xs, ys = zip(*xys)
+ xmin, xmax = min(xmin, float(min(xs))), max(xmax, float(max(xs)))
+ ymin, ymax = min(ymin, float(min(ys))), max(ymax, float(max(ys)))
+ plot.set_xlim(xmin, xmax)
+ plot.set_ylim(ymin, ymax)
plot.add_patch(Polygon(xys, closed=True, **kwargs))
return plot
if plot is None:
fig = plt.figure()
axes = Axes3D(fig)
- xmin, xmax = float('inf'), float('-inf')
- ymin, ymax = float('inf'), float('-inf')
- zmin, zmax = float('inf'), float('-inf')
else:
axes = plot
+ xmin, xmax = axes.get_xlim()
+ ymin, ymax = axes.get_xlim()
+ zmin, zmax = axes.get_xlim()
poly_xyzs = []
for vertices in self.faces():
if len(vertices) == 0:
vertices = Polyhedron._sort_polygon_3d(vertices)
vertices.append(vertices[0])
face_xyzs = [tuple(vertex.values()) for vertex in vertices]
- if plot is None:
- xs, ys, zs = zip(*face_xyzs)
- xmin, xmax = min(xmin, float(min(xs))), max(xmax, float(max(xs)))
- ymin, ymax = min(ymin, float(min(ys))), max(ymax, float(max(ys)))
- zmin, zmax = min(zmin, float(min(zs))), max(zmax, float(max(zs)))
+ xs, ys, zs = zip(*face_xyzs)
+ xmin, xmax = min(xmin, float(min(xs))), max(xmax, float(max(xs)))
+ ymin, ymax = min(ymin, float(min(ys))), max(ymax, float(max(ys)))
+ zmin, zmax = min(zmin, float(min(zs))), max(zmax, float(max(zs)))
poly_xyzs.append(face_xyzs)
collection = Poly3DCollection(poly_xyzs, **kwargs)
axes.add_collection3d(collection)
- if plot is None:
- axes.set_xlim(xmin, xmax)
- axes.set_ylim(ymin, ymax)
- axes.set_zlim(zmin, zmax)
+ axes.set_xlim(xmin, xmax)
+ axes.set_ylim(ymin, ymax)
+ axes.set_zlim(zmin, zmax)
return axes
def plot(self, plot=None, **kwargs):