5

I am attempting to create a plane in an mplot3d plot that touches all axes walls. The axes limits are set using ax.set_xlim(-6.0,6.0) or ax,set_xlim3d(-6.0,6.0). In both cases, the walls are drawn slightly outside the specified limits. Drawing my plane using Poly3DCollection results in the plane drawn correctly, however, it does not touch the axes walls.

I am using (the setting of the colours for the grid and walls are included as the default colour on my screen at least looks rather light and thus obscures the "feature")

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
from mpl_toolkits.mplot3d.art3d import Poly3DCollection

fig = plt.figure()
ax = fig.add_subplot(111,projection='3d')

ax.set_xlim(-6.0, 6.0)
ax.set_ylim(-6.0, 6.0)
ax.set_zlim(-1.0, 1.0)

ax.w_xaxis.set_pane_color((.85, .85, .85, 1.0))
ax.w_yaxis.set_pane_color((.85, .85, .85, 1.0))
ax.w_zaxis.set_pane_color((.85, .85, .85, 1.0))

ax.w_xaxis._axinfo.update({"grid": {"color": (.7, .7, .7, 1)}})
ax.w_yaxis._axinfo.update({"grid": {"color": (.7, .7, .7, 1)}})
ax.w_zaxis._axinfo.update({"grid": {"color": (.7, .7, .7, 1)}})

x = [-6,6,6,-6]
y = [-6,-6,6,6]
z = [0,0,0,0]

verts = [zip(x,y,z)]
collection = Poly3DCollection(verts)
collection.set_color("green")
ax.add_collection3d(collection)

plt.tight_layout()

plt.show()

The plot looks like this example

I already searched here for a solution here and found two posts having the same "problem" (question 1 and question 2), unfortunately both are currently unresolved.

How can I achieve that the plane touches the outside walls a) by restricting the walls to the set limits of the axes or b) by enlarging my plane do include that extra little space?

Community
  • 1
  • 1
Annika
  • 137
  • 2
  • 7

0 Answers0