In [1]:
import numpy as np
import matplotlib.pyplot as plt
# %matplotlib widget
In [2]:
axes = [4, 3, 2]
data = np.ones(axes)
In [3]:
data
Out[3]:
In [4]:
fig = plt.figure(figsize = (6, 6))
ax = plt.axes(projection = '3d', box_aspect = (1, 1, 1))
# ax.plot(*p1, color = 'blue', marker = 'o')
# ax.text(p1[0] + 0.25, p1[1] + 0.25, p1[2] + 0.25, s = p1, fontsize = 12)
# ax.plot(*p2, color = 'blue', marker = 'o')
# ax.text(p2[0] + 0.25, p2[1] + 0.25, p2[2] + 0.25, s = p2, fontsize = 12)
ax.voxels(data, facecolors = [1, 0, 0, 0.5], edgecolors = [1, 0, 0, 0])
ax.set_xticks(np.arange(-5, 6))
ax.set_yticks(np.arange(-5, 6))
ax.set_zticks(np.arange(-5, 6))
ax.set_xlim(-5, 5)
ax.set_ylim(-5, 5)
ax.set_zlim(-5, 5)
plt.grid()
plt.axis('off')
Out[4]:
In [5]:
center = np.array([0, 0, 0])
In [6]:
phi = np.arange(1,10,2)*np.pi/4
Phi, Theta = np.meshgrid(phi, phi)
a = 4
b = 7
c = 3
x = a * np.cos(Phi)*np.sin(Theta) + center[0]
y = b * np.sin(Phi)*np.sin(Theta) + center[1]
z = c * np.cos(Theta)/np.sqrt(2) + center[2]
In [7]:
fig = plt.figure(figsize = (6, 6))
ax = plt.axes(projection = '3d', box_aspect = (1, 1, 1))
ax.plot_surface(x, y, z, color = 'blue', alpha = 0.3)
ax.set_xlim(-8,8)
ax.set_ylim(-8,8)
ax.set_zlim(-8,8)
plt.show()
In [ ]:
In [ ]:
In [ ]: