0

In a standard 3D python plot, each data point is, by default, represented as a sphere in 3D. For the data I'm plotting, the z-axis is very sensitive, while the x and y axes are very general, so is there a way to make each point on the scatter plot spread out over the x and y direction as it normally would with, for example, s=500, but not spread at all along the z-axis? Ideally this would look like a set of stacked discs, rather than overlapping spheres.

Any ideas? I'm relatively new to python and I don't know if there's a way to make custom data points like this with a scatter plot.

NGXII
  • 407
  • 2
  • 9
  • 18

2 Answers2

1

I actually was able to do this using the matplotlib.patches library, creating a patch for every data point, and then making it whatever shape I wanted with the help of mpl_toolkits.mplot3d.art3d.

NGXII
  • 407
  • 2
  • 9
  • 18
0

You might look for something called "jittering". Take a look at Matplotlib: avoiding overlapping datapoints in a "scatter/dot/beeswarm" plot It works by adding random noise to your data.

Another way might be to reduce the variance of the data on your z-axis (e.g. applying a log-function) or adjusting the scale. You could do that with ax.set_zscale("log"). It is documented here http://matplotlib.org/mpl_toolkits/mplot3d/api.html#mpl_toolkits.mplot3d.axes3d.Axes3D.set_zscale

Community
  • 1
  • 1
JAyP
  • 75
  • 5