I tried to change the contour graphs by mixing the data calculated as the sum along the axis with the grid created by np.mgrid . I calculated the sum of the density along the axis on which I want to have a path. It looks like this:
# plot projection of density onto z-axis plotdat = np.sum(density, axis=2) plotdat = plotdat / np.max(plotdat) plotx, ploty = np.mgrid[-4:4:100j, -4:4:100j] ax.contour(plotx, ploty, plotdat, offset=-4, zdir='z') #This is new #plot projection of density onto y-axis plotdat = np.sum(density, axis=1) #summing up density along y-axis plotdat = plotdat / np.max(plotdat) plotx, plotz = np.mgrid[-4:4:100j, -4:4:100j] ax.contour(plotx, plotdat, plotz, offset=4, zdir='y') #plot projection of density onto x-axis plotdat = np.sum(density, axis=0) #summing up density along z-axis plotdat = plotdat / np.max(plotdat) ploty, plotz = np.mgrid[-4:4:100j, -4:4:100j] ax.contour(plotdat, ploty, plotz, offset=-4, zdir='x') #continue with your code
Unfortunately, I am not very familiar with estimating the kernel density, so I hope I didnโt understand something completely wrong, but the result generated by adding a few lines of code above looks something like your imaginary paint image :) 
source share