Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ea64cd

Browse files
Put edge-on axes on left and right when viewing 3d axis planes
1 parent 2da3401 commit 0ea64cd

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,34 @@ def _get_coord_info(self, renderer):
231231
bounds_proj = self.axes.tunit_cube(bounds, self.axes.M)
232232

233233
# Determine which one of the parallel planes are higher up:
234-
highs = np.zeros(3, dtype=bool)
234+
means_z0 = np.zeros(3)
235+
means_z1 = np.zeros(3)
235236
for i in range(3):
236-
mean_z0 = np.mean(bounds_proj[self._PLANES[2 * i], 2])
237-
mean_z1 = np.mean(bounds_proj[self._PLANES[2 * i + 1], 2])
238-
highs[i] = mean_z0 < mean_z1
237+
means_z0[i] = np.mean(bounds_proj[self._PLANES[2 * i], 2])
238+
means_z1[i] = np.mean(bounds_proj[self._PLANES[2 * i + 1], 2])
239+
highs = means_z0 < means_z1
240+
241+
# Special handling for edge-on views
242+
equals = np.abs(means_z0 - means_z1) <= np.finfo(float).eps
243+
if np.sum(equals) == 2:
244+
vertical = np.where(np.invert(equals))[0][0]
245+
if vertical == 2:
246+
if highs[2]: # looking at -XY plane
247+
highs[0] = False
248+
highs[1] = True
249+
else: # looking at +XY plane
250+
highs[0] = True
251+
highs[1] = True
252+
elif vertical == 1:
253+
if highs[1]: # looking at +XZ plane
254+
highs[0] = True
255+
else: # looking at -XZ plane
256+
pass
257+
elif vertical == 0:
258+
if highs[0]: # looking at -YZ plane
259+
highs[1] = True
260+
else: # looking at +YZ plane
261+
pass
239262

240263
return mins, maxs, centers, deltas, bounds_proj, highs
241264

0 commit comments

Comments
 (0)