ericmjl
ericmjl

Reputation: 14684

Is there a way to use matplotlib to make a "3D cloud plot"?

I have a chart that I made - it's a 3D scatterplot, with 2000 data points plotted per colour. Please see chart below:

enter image description here

I used matplotlib's 3D scatter plot to make this.

I was wondering if there's a way to make this into a "cloud" plot of sorts? Sort of like a bounding cloud/box that envelopes where all (or the majority) of the blue or green points lie. My goal is to visualize the separation between the two colours. Granted, that is possible now, but I thought maybe a "cloud" plot might be clearer?

As I was unable to find anything on these kinds of plots using raw data, I have yet to code anything up.

Upvotes: 2

Views: 3007

Answers (1)

behzad.nouri
behzad.nouri

Reputation: 77941

Not exactly a cloud, but more of an idea: you may use scipy.interpolate.interp2d, to interpolate your data on denser mesh. Then plot the data with:

  • larger marker size: say s=200
  • lower alpha, say alpha=.1
  • a color-map which changes to white in the middle, say cmap='PRGn'

then

 ax.scatter(xs, ys, zs, c=zs, marker='D', s=200, alpha=.1, cmap='PRGn')

would give you this:

cloud

Upvotes: 3

Related Questions