Skip to content Skip to sidebar Skip to footer

3d Figures From Matplotlib Visibility Of Pane Edge

I am not able to get the left pane edge visible. %pylab inline from mpl_toolkits.mplot3d import axes3d rcdefaults() x, y = meshgrid(linspace(-10, 10, 100), linspace(-10, 10, 100))

Solution 1:

So here is my somewhat hacky answer or better said workaround for this problem:

%pylab inline
%matplotlib notebook
%matplotlib notebook
from mpl_toolkits.mplot3d import axes3d, art3d
rcdefaults()

x, y = meshgrid(linspace(-10, 10, 100), linspace(-10, 10, 100))
z = x**2+y**2

fig = figure()
ax3D = fig.add_subplot(111, projection='3d')
ax3D.plot_surface(x, y, z, rstride=8, cstride=8, alpha=0.3, cmap='hot')

deflims(mplotlims):
    scale = 1.021
    offset = (mplotlims[1] - mplotlims[0])*scale
    return mplotlims[1] - offset, mplotlims[0] + offset
xlims, ylims, zlims = lims(ax3D.get_xlim()), lims(ax3D.get_ylim()), lims(ax3D.get_zlim())
ax3D.contour(x, y, z, zdir='x', offset=xlims[0])
ax3D.contour(x, y, z, zdir='y', offset=ylims[1])
ax3D.contour(x, y, z, zdir='z', offset=zlims[0])
i = array([xlims[0], ylims[0], zlims[0]])
f = array([xlims[0], ylims[0], zlims[1]])
p = art3d.Poly3DCollection(array([[i, f]]))
p.set_color('black')
ax3D.add_collection3d(p)

ax3D.xaxis.pane.set_edgecolor('#000000')
ax3D.yaxis.pane.set_edgecolor('#000000')
ax3D.zaxis.pane.set_edgecolor('#000000')
ax3D.xaxis.pane.set_alpha(1)
ax3D.yaxis.pane.set_alpha(1)
ax3D.zaxis.pane.set_alpha(1)
ax3D.xaxis.pane.fill = False
ax3D.yaxis.pane.fill = False
ax3D.zaxis.pane.fill = False
fig.tight_layout()
show()

enter image description here

Post a Comment for "3d Figures From Matplotlib Visibility Of Pane Edge"