I would like to draw a parallelepiped in Python using matplotlib centred in (0,0,0), with the top face of a different color (or each face of a different parametrized color), and with these dimensions:
This is the code I developed to draw a cube with the same face color.
import matplotlib.pyplot as plt import numpy as np # Create axis axes = [5, 5, 5] # Create Data data = np.ones(axes, dtype = np.bool) # Control Tranperency alpha = 0.9 # Control colour colors = np.empty(axes + , dtype = np.float32) colors[:] = [1, 0, 0, alpha] # red # Plot figure fig2 = plt.figure() ax = fig2.add_subplot(111, projection='3d') ax.voxels(data, facecolors=colors)
Any suggestion to modify it? Considering that I would like to rotate it with a rotation matrix/quaternion operator in a second time, it would be useful to define the coordinates of the vertices or of some ley points of the parallelepiped.
thank you all!
Leave an answer