Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1f1eab9

Browse filesBrowse files
authored
Merge pull request #20242 from Illviljan/Illviljan-format_get_coord_info
Add comments and format Axis._get_coord_info
2 parents 9c9e0a0 + c6bb5b6 commit 1f1eab9
Copy full SHA for 1f1eab9

File tree

Expand file treeCollapse file tree

1 file changed

+22
-12
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-12
lines changed

‎lib/mpl_toolkits/mplot3d/axis3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/axis3d.py
+22-12Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,28 @@ def _get_coord_info(self, renderer):
183183
self.axes.get_ybound(),
184184
self.axes.get_zbound(),
185185
]).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
186+
187+
# Get the mean value for each bound:
188+
centers = 0.5 * (maxs + mins)
189+
190+
# Add a small offset between min/max point and the edge of the
191+
# plot:
192+
deltas = (maxs - mins) / 12
193+
mins -= 0.25 * deltas
194+
maxs += 0.25 * deltas
195+
196+
# Project the bounds along the current position of the cube:
197+
bounds = mins[0], maxs[0], mins[1], maxs[1], mins[2], maxs[2]
198+
bounds_proj = self.axes.tunit_cube(bounds, self.axes.M)
199+
200+
# Determine which one of the parallel planes are higher up:
201+
highs = np.zeros(3, dtype=bool)
202+
for i in range(3):
203+
mean_z0 = np.mean(bounds_proj[self._PLANES[2 * i], 2])
204+
mean_z1 = np.mean(bounds_proj[self._PLANES[2 * i + 1], 2])
205+
highs[i] = mean_z0 < mean_z1
206+
207+
return mins, maxs, centers, deltas, bounds_proj, highs
198208

199209
def draw_pane(self, renderer):
200210
renderer.open_group('pane3d', gid=self.get_gid())

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.