diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 0a8103287110..791e783563df 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -1733,11 +1733,14 @@ def _generate_normals(self, polygons): Generate normals for polygons by using the first three points. This normal of course might not make sense for polygons with more than three points not lying in a plane. + + Normals point towards the viewer for a face with its vertices in + counterclockwise order, following the right hand rule. ''' normals = [] for verts in polygons: - v1 = np.array(verts[0]) - np.array(verts[1]) + v1 = np.array(verts[1]) - np.array(verts[0]) v2 = np.array(verts[2]) - np.array(verts[0]) normals.append(np.cross(v1, v2)) return normals @@ -2449,48 +2452,50 @@ def bar3d(self, x, y, z, dx, dy, dz, color=None, maxz = np.max(z + dz) # shape (6, 4, 3) + # All faces are oriented facing outwards - when viewed from the + # outside, their vertices are in a counterclockwise ordering. cuboid = np.array([ # -z ( (0, 0, 0), - (1, 0, 0), + (0, 1, 0), (1, 1, 0), - (0, 1, 0) + (1, 0, 0), ), # +z ( (0, 0, 1), (1, 0, 1), (1, 1, 1), - (0, 1, 1) + (0, 1, 1), ), # -y ( (0, 0, 0), (1, 0, 0), (1, 0, 1), - (0, 0, 1) + (0, 0, 1), ), # +y ( (0, 1, 0), - (1, 1, 0), + (0, 1, 1), (1, 1, 1), - (0, 1, 1) + (1, 1, 0), ), # -x ( (0, 0, 0), - (0, 1, 0), + (0, 0, 1), (0, 1, 1), - (0, 0, 1) + (0, 1, 0), ), # +x ( (1, 0, 0), (1, 1, 0), (1, 1, 1), - (1, 0, 1) + (1, 0, 1), ), ]) diff --git a/lib/mpl_toolkits/tests/baseline_images/test_mplot3d/bar3d_notshaded.png b/lib/mpl_toolkits/tests/baseline_images/test_mplot3d/bar3d_notshaded.png index 0a8dff8d1b41..54a515024a36 100644 Binary files a/lib/mpl_toolkits/tests/baseline_images/test_mplot3d/bar3d_notshaded.png and b/lib/mpl_toolkits/tests/baseline_images/test_mplot3d/bar3d_notshaded.png differ diff --git a/lib/mpl_toolkits/tests/baseline_images/test_mplot3d/bar3d_shaded.png b/lib/mpl_toolkits/tests/baseline_images/test_mplot3d/bar3d_shaded.png index e1f7e35f1830..f35d62c15513 100644 Binary files a/lib/mpl_toolkits/tests/baseline_images/test_mplot3d/bar3d_shaded.png and b/lib/mpl_toolkits/tests/baseline_images/test_mplot3d/bar3d_shaded.png differ