In [23]:
# Plot a hypercube with points
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from itertools import product, combinations
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_aspect("equal")
# draw cube
r = [0, 1]
for s, e in combinations(np.array(list(product(r, r, r))), 2):
if np.sum(np.abs(s-e)) == r[1]-r[0]:
ax.plot3D(*zip(s, e), color="black")
# draw a point
ax.scatter(np.random.rand(50), np.random.rand(50), np.random.rand(50), color="black")
ax.scatter(np.random.rand(5), np.random.rand(5), np.random.rand(5), color="red")
ax.scatter(np.random.rand(5), np.random.rand(5), np.random.rand(5), color="green")
ax.set_axis_off()
plt.savefig('cube.pdf',bbox_inches='tight')
plt.show()
In [ ]:
In [ ]: