So I found a custom script to make a waterfall plot from a dataframe, which I customized for my purposes. When I run the function for small number of columns, each layer plots accordingly with the subsequent plot properly placed behind the previous plot. When I keep including a larger number of the columns, it starts plotting subsequent plots over the previous ones.
I tried using PolyCollections, and LineCollections and I can't seem to fix this. Is it a bug? Is there a work-around?
def waterfall(X, numTrials):
# Function to generate formats for facecolors
cc = lambda arg: colorConverter.to_rgba(arg, alpha=1)
# This is just wrong. There must be some way to use the meshgrid or why bother.
verts = []
for i in np.arange(numTrials)+1:
verts.append(list(zip(X['Time'].values, X['Trial #'+str(i)].values)))
xmin = np.floor(np.min(X['Time'].values))
xmax = np.ceil(np.max(X['Time'].values))
ymin = -1
ymax = numTrials+1
zmin = np.floor(np.min(X.drop(columns=['Time']).values))
zmax = np.ceil(np.max(X.drop(columns=['Time']).values))
fig=plt.figure()
fig.set_size_inches(15,10)
ax = Axes3D(fig)
poly = PolyCollection(verts,closed='True',edgecolors=[cc('k')],facecolors=[cc('w')])
ax.add_collection3d(poly, zs=np.arange(numTrials)+1, zdir='y')
ax.set_xlim(xmin,xmax)
ax.set_ylim(ymin,ymax)
ax.set_zlim(zmin,zmax)
ax.view_init(25, -110)
plt.show()
for x in np.arange(5,100,20):
waterfall(CRresponse, x)
This is an example of a proper output, for low number of columns: enter image description here
This is an example of a messed up output for higher number of columns: enter image description here
Thank you for any help on the matter, and I appreciate your patience for a first time poster