# [Matplotlib-users] Creating a smooth surface in 3D

Benjamin Root ben.v.root at gmail.com
Mon May 28 09:19:02 EDT 2018

```mplot3d is good for real simple 3d scenes, but it falls apart when you
start composing things like this. You might want to consider using
something like glumpy or mayavi for better results. There are some
discussions in the past on the problems inherent in creating spheres in
mplot3d. There are some interesting solutions, but they get fairly complex
pretty quickly.

Cheers!
Ben Root

On Mon, May 28, 2018 at 8:16 AM, Bala subramanian <bala.biophysics at gmail.com
> wrote:

> Dear mpl friends,
>
> My objective is to create a molecular surface using matplotlib. I used the
> snippet pasted below to create a series of spheres (attached png), drawn
> using the atom attributes (their positions and radius). From here, I would
> like to create a smooth surface which can depict the shape of the molecule
> surface (curves,cavities etc). Based on examples in net, I get a mixed
> feeling that either triangulation or making 3D grids are some directions to
> proceed. If anyone has some suggestions or better protocols for such task
> with some example data, it would be of great help to me.
>
> fig = plt.figure(figsize=(6,6),dpi=140)
>
>
> # Define spherical coordinates
>
> u, v = np.mgrid[0:2*np.pi:20j, 0:np.pi:10j]
>
> S = np.cos(u)*np.sin(v)
>
> C = np.sin(u)*np.sin(v)
>
> T = np.cos(v)
>
>
>          ax1.plot_wireframe(R*S+P[0],R*C+P[1],R*T+P[2],color='r',alph
> a=0.4)
>
>
> Bala
>
>
> --
> C. Balasubramanian
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180528/a3577021/attachment.html>
```