@@ -178,23 +178,35 @@ def get_rotate_label(self, text):
178178 return len (text ) > 4
179179
180180 def _get_coord_info (self , renderer ):
181- mins , maxs = np .array ([
182- self .axes .get_xbound (),
183- self .axes .get_ybound (),
184- self .axes .get_zbound (),
185- ]).T
186- centers = (maxs + mins ) / 2.
187- deltas = (maxs - mins ) / 12.
188- mins = mins - deltas / 4.
189- maxs = maxs + deltas / 4.
190-
191- vals = mins [0 ], maxs [0 ], mins [1 ], maxs [1 ], mins [2 ], maxs [2 ]
192- tc = self .axes .tunit_cube (vals , self .axes .M )
193- avgz = [tc [p1 ][2 ] + tc [p2 ][2 ] + tc [p3 ][2 ] + tc [p4 ][2 ]
194- for p1 , p2 , p3 , p4 in self ._PLANES ]
195- highs = np .array ([avgz [2 * i ] < avgz [2 * i + 1 ] for i in range (3 )])
196-
197- return mins , maxs , centers , deltas , tc , highs
181+ mins , maxs = np .array (
182+ [
183+ self .axes .get_xbound (),
184+ self .axes .get_ybound (),
185+ self .axes .get_zbound (),
186+ ]
187+ ).T
188+
189+ # Get the mean value for each bound:
190+ centers = 0.5 * (maxs + mins )
191+
192+ # Add a small offset between min/max point and the edge of the
193+ # plot:
194+ deltas = (maxs - mins ) / 12.0
195+ mins -= 0.25 * deltas
196+ maxs += 0.25 * deltas
197+
198+ # Project the bounds along the current position of the cube:
199+ bounds = mins [0 ], maxs [0 ], mins [1 ], maxs [1 ], mins [2 ], maxs [2 ]
200+ bounds_proj = self .axes .tunit_cube (bounds , self .axes .M )
201+
202+ # Determine which one of the parallel planes are higher up:
203+ highs = np .zeros (3 , dtype = bool )
204+ for i in range (3 ):
205+ mean_z0 = np .mean (bounds_proj [self ._PLANES [2 * i ], 2 ])
206+ mean_z1 = np .mean (bounds_proj [self ._PLANES [2 * i + 1 ], 2 ])
207+ highs [i ] = mean_z0 < mean_z1
208+
209+ return mins , maxs , centers , deltas , bounds_proj , highs
198210
199211 def draw_pane (self , renderer ):
200212 renderer .open_group ('pane3d' , gid = self .get_gid ())
0 commit comments