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

Skip to content

Commit 7a7e317

Browse files
committed
Makes 3D labelpads more invariant with figure size
1 parent 6412735 commit 7a7e317

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ class Axis(maxis.XAxis):
7070
'color': (0.925, 0.925, 0.925, 0.5)},
7171
}
7272

73-
# Factors for converting 2D labelpad properties to 3D
74-
# Determined by trial and error
75-
_DELTAS_PER_POINT = 0.05
76-
_DEFAULT_LABEL_OFFSET = 1.35 # In deltas
77-
7873
def __init__(self, adir, v_intervalx, d_intervalx, axes, *args, **kwargs):
7974
# adir identifies which axes this is
8075
self.adir = adir
@@ -269,8 +264,11 @@ def draw(self, renderer):
269264

270265
lxyz = 0.5*(edgep1 + edgep2)
271266

272-
labeldeltas = (self.labelpad * self._DELTAS_PER_POINT +
273-
self._DEFAULT_LABEL_OFFSET) * deltas
267+
# A rough estimate; points are ambiguous since 3D plots rotate
268+
deltas_per_point = 48 / (self.axes.bbox.height + self.axes.bbox.width)
269+
default_offset = 30
270+
labeldeltas = (self.labelpad + default_offset) * deltas_per_point\
271+
* deltas
274272
axmask = [True, True, True]
275273
axmask[index] = False
276274
lxyz = move_from_center(lxyz, centers, labeldeltas, axmask)

0 commit comments

Comments
 (0)