8

The following code plots points at the tips of a neuron skeleton, the coordinates of which are stored in coords, and the colors of which are stored in tcolors (which, for some reason, only colors the outline of the markers rather than the interior, creating another problem).

# Plot and color points at tips by path distance
for t, pts in enumerate(coords):
    ax.scatter(pts[0], pts[1], pts[2], color=tcolors[t],
               alpha=0.9, marker = 'o', s = 100)

Here is what it looks like:

https://gfycat.com/SkeletalFarawayBird

Unsurprisingly, the markers are circles (i.e. marker = 'o'). I am fully aware of how to change the marker into any of a number of 2D shapes (explained here), but I have no idea how to plot 3D shapes as markers in matplotlib.

My best solution is to manually, and rather inefficiently, plot spheres possessing origins at the specified coordinates. However, as is the reason why I am posting here, I am sure there is a better and, hopefully, matplotlib-native solution to this problem.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Cosmo
  • 210
  • 5
  • 9
  • 1
    I wouldn't be so sure. [Matplotlib does not have a good 3D engine](http://stackoverflow.com/questions/37488379/matplotlib-3dplot-extra-lines-when-dimensions-not-equal/37489040#37489040) at the moment. Try and see if the following question helps you at all: http://stackoverflow.com/questions/24123659/scatter-plot-3d-with-labels-and-spheres – armatita Jun 11 '16 at 16:53
  • @armatita Wow, thanks a million for that first link! You've actually answered several other questions I've had but had yet to ask. While I still desire a more elegant solution to my problem, I'll happily adapt the one proposed in your second link for my own code as a temporary fix. However, do you think that no better solution is possible? Thanks for your help. – Cosmo Jun 13 '16 at 18:35
  • Hopefully it will be when OpenGl support is added. Until than you should consider using the plentiful universe of 3D engines in Python. My answer in the first link is actually a quote from the Matplotlib site. They recommend Mayavi. I've used it a lot but last time I saw it didn't had Python 3 support. As so I recommend Pyqtgraph or Vispy. – armatita Jun 13 '16 at 18:51

0 Answers0