I have three numbers representing lengths. Each number is the length of an object on the x, y, and z axes. The object I want to represent is (probably) a deformed sphere.
How can I 3D plot this object by specifying these 3 lengths ?
I would like to go from this:
To something like this, for example (I just dilated the picture):
I tried to take the following code (from Ellipsoid creation in Python) and play a bit with the definition of x, y, and z:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
phi = np.linspace(0,2*np.pi, 256).reshape(256, 1) # the angle of the projection in the xy-plane
theta = np.linspace(0, np.pi, 256).reshape(-1, 256) # the angle from the polar axis, ie the polar angle
radius = 4
# Transformation formulae for a spherical coordinate system.
x = radius*np.sin(theta)*np.cos(phi)
y = radius*np.sin(theta)*np.sin(phi)
z = radius*np.cos(theta)
fig = plt.figure(figsize=plt.figaspect(1)) # Square figure
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(x, y, z, color='b')
But I can't reach what I want. Could you give me a hand please ?