three d shapes mayavi python

preview_player
Показать описание
# Import necessary libraries
from mayavi import mlab
import numpy as np

# Create a larger figure (800x800 window)

# ------------------ Red Sphere ------------------
# Generate sphere data
sphere = x_sphere**2 + y_sphere**2 + z_sphere**2
# Display red sphere

# ------------------ Green Cone ------------------
# Generate cone data
z_cone = r_grid # linearly increase z for cone height
# Display green cone

# ------------------ Blue Cylinder ------------------
# Generate cylinder data
# Display blue cylinder

# ------------------ Add 2D Fixed Text ------------------
# Add descriptive text
"a red sphere, a green cone, and a blue cylinder, all displayed in\n"
"a larger figure (800x800 window) with a black background.",
width=0.9, color=(1, 1, 0)) # Yellow text, 90% width of the window

# Add "created by arvind 22/9/24" text at the bottom

# Display the shapes and text in the same window
Рекомендации по теме