Generally speaking, a plottable 3D surface can be represented
parametrically in 2D (hence why it is a surface). Your point cloud can not
be represented parametrically in 2 dimensions, hence why you are having
difficulty figuring out how to plot it as a surface. I used to have similar
problems with 3D plotting (both here and in Matlab) before I came to this
realization.

Your comment "of course, plotting a sphere can be done in spherical
coordinates" is actually the right thought process. Spherical coordinates
is how you parametrize your spherical surface. Pick a coordinate system
that is relevant to your problem at hand and use it.

I hope this helps!
Ben Root


On Sat, Nov 1, 2014 at 2:07 PM, Peter Kerpedjiev <pkerpedj...@gmail.com>
wrote:

> Hi,
>
> I'm trying to plot an outline of an arbitrary 3D shape using
> matplotlib's plot_surface, and I wanted to ask if any one has any ideas
> as to how to do it. Here's the beginnings of a simple example:
>
> # create a grid
> resolution = 10
>
> xs = np.linspace(-1,1,resolution)
> ys = np.linspace(-1,1,resolution)
> zs = np.linspace(-1,1,resolution)
>
> X,Y,Z = np.meshgrid(xs, ys, zs)
>
> #Then we can calculate the square of the distance of each point to the
> center:
> W = X**2 + Y**2 + Z**2
>
> # Let's see which points are within a certain radius:
> C = W < 1.
>
> # this can be used to create a point-cloud
> x = X[C]
> y = Y[C]
> z = Z[C]
>
>  From this I tried a lot options, the best being to do some XOR
> operations on the array C to get a list of points which are on the
> surface of the sphere. My question is, can anybody see a reasonable way
> to plot this surface using mplot3D?
>
> Of course plotting a sphere can be done using spherical coordinates, but
> that defeats the purpose of this example :) This is just a
> simplification as the application is actually to draw 3D contours (i.e.
> shapes, rather than iso-lines) of a three-parameter probability
> distribution.
>
> Thanks in advance,
>
> -Peter
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to