'How draw implict 3D surface with sympy?

I try to draw x**2 + y**3 = z**2 use sympy, but I don't how to draw it.

I use plot3d(x**2 + y**3-z**2) but it don't work at all, So can someone know how to do?



Solution 1:[1]

Sadly, Sympy doesn't support 3d implicit plots. However, sage does, though I remember it was a very heavy module to install.

Alternatively, if you are using Jupyter Notebook you can use K3D-Jupyter which is capable of plotting implicit surfaces. Let's see how to plot your surface:

import k3d
import numpy as np

r = 5
zmin, zmax = -r, r
xmin, xmax = -r, r
ymin, ymax = -r, r
Nx, Ny, Nz = 100, 100, 100

x = np.linspace(xmin, xmax, Nx, dtype=np.float32)
y = np.linspace(ymin, ymax, Ny, dtype=np.float32)
z = np.linspace(zmin, zmax, Nz, dtype=np.float32)
x, y, z = np.meshgrid(x, y, z, indexing='ij')
p = x**2 + y**3 - z**2

plot = k3d.plot()
plt_iso = k3d.marching_cubes(p, compression_level=9, xmin=xmin, xmax=xmax,
                             ymin=ymin, ymax=ymax,
                             zmin=zmin, zmax=zmax, level=0.0,
                             flat_shading=False)
plot += plt_iso
plot.display()

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Davide_sd