2

I would like to visualize 2D slices in a 3D plot by means of matplotlib and Axes3D, with some transparency to have a better view, as represented by

picture depicting my data

where the 2D slices clearly overlap. These slices are produced by pcolor, which in contrast to pcolormesh, returns a matplotlib.collections.Collection object and consequently can be handled by add_collection3d.

The issue of carrying the transparency property has already been discussed there and there, although the workarounds suggested (in Python comments below) haven't had any effect with my issue. My sample code is something along the lines of

import numpy             as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d   import Axes3D
from matplotlib.collections import PolyCollection

X, Y = np.meshgrid(x,y)

fig = plt.figure()
ax = fig.gca(projection='3d')

alpha = 0.8

for i in range(len(islices)):
    im = ax.pcolor(X,Y,u[islices[i],:,:]) #,alpha=alpha)
    #im.set_facecolor((0, 0, 1, alpha))
    ax.add_collection3d(im,zs=xslices[i],zdir='y')

plt.show()

0 Answers0