Skip to content

Commit fdb32e9

Browse files
scottshambaughQuLogic
authored andcommitted
Standardize edge-on axis locations when viewing primary 3d axis planes (matplotlib#23644)
* Put edge-on axes on left and right when viewing 3d axis planes Tests Fix broken tests Clean up test Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
1 parent fc56c5b commit fdb32e9

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎lib/mpl_toolkits/mplot3d/axis3d.py‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,23 @@ def _get_coord_info(self, renderer):
244244
bounds_proj = self.axes.tunit_cube(bounds, self.axes.M)
245245

246246
# Determine which one of the parallel planes are higher up:
247-
highs = np.zeros(3, dtype=bool)
247+
means_z0 = np.zeros(3)
248+
means_z1 = np.zeros(3)
248249
for i in range(3):
249-
mean_z0 = np.mean(bounds_proj[self._PLANES[2 * i], 2])
250-
mean_z1 = np.mean(bounds_proj[self._PLANES[2 * i + 1], 2])
251-
highs[i] = mean_z0 < mean_z1
250+
means_z0[i] = np.mean(bounds_proj[self._PLANES[2 * i], 2])
251+
means_z1[i] = np.mean(bounds_proj[self._PLANES[2 * i + 1], 2])
252+
highs = means_z0 < means_z1
253+
254+
# Special handling for edge-on views
255+
equals = np.abs(means_z0 - means_z1) <= np.finfo(float).eps
256+
if np.sum(equals) == 2:
257+
vertical = np.where(~equals)[0][0]
258+
if vertical == 2: # looking at XY plane
259+
highs = np.array([True, True, highs[2]])
260+
elif vertical == 1: # looking at XZ plane
261+
highs = np.array([True, highs[1], False])
262+
elif vertical == 0: # looking at YZ plane
263+
highs = np.array([highs[0], False, False])
252264

253265
return mins, maxs, centers, deltas, bounds_proj, highs
254266

10.5 KB
Loading
244 Bytes
Loading

0 commit comments

Comments
 (0)