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

Skip to content

Commit fac3a18

Browse files
Make focal_length a private attr
1 parent 6994846 commit fac3a18

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,17 +1049,17 @@ def set_proj_type(self, proj_type, focal_length=None):
10491049
_api.check_in_list(['persp', 'ortho'], proj_type=proj_type)
10501050
if proj_type == 'persp':
10511051
if focal_length is None:
1052-
self.focal_length = 1
1052+
self._focal_length = 1
10531053
else:
10541054
if focal_length <= 0:
10551055
raise ValueError(f"focal_length = {focal_length} must be"
10561056
" greater than 0")
1057-
self.focal_length = focal_length
1057+
self._focal_length = focal_length
10581058
elif proj_type == 'ortho':
10591059
if focal_length not in (None, np.inf):
10601060
raise ValueError(f"focal_length = {focal_length} must be"
10611061
f"None for proj_type = {proj_type}")
1062-
self.focal_length = np.inf
1062+
self._focal_length = np.inf
10631063

10641064
def _roll_to_vertical(self, arr):
10651065
"""Roll arrays to match the different vertical axis."""
@@ -1116,18 +1116,18 @@ def get_proj(self):
11161116
V[self._vertical_axis] = -1 if abs(elev_rad) > 0.5 * np.pi else 1
11171117

11181118
# Generate the view and projection transformation matrices
1119-
if self.focal_length == np.inf:
1119+
if self._focal_length == np.inf:
11201120
# Orthographic projection
11211121
viewM = proj3d.view_transformation(eye, R, V, roll_rad)
11221122
projM = proj3d.ortho_transformation(-self.dist, self.dist)
11231123
else:
11241124
# Perspective projection
11251125
# Scale the eye dist to compensate for the focal length zoom effect
1126-
eye_focal = R + self.dist * ps * self.focal_length
1126+
eye_focal = R + self.dist * ps * self._focal_length
11271127
viewM = proj3d.view_transformation(eye_focal, R, V, roll_rad)
11281128
projM = proj3d.persp_transformation(-self.dist,
11291129
self.dist,
1130-
self.focal_length)
1130+
self._focal_length)
11311131

11321132
# Combine all the transformation matrices to get the final projection
11331133
M0 = np.dot(viewM, worldM)
@@ -1192,7 +1192,7 @@ def cla(self):
11921192
pass
11931193

11941194
self._autoscaleZon = True
1195-
if self.focal_length == np.inf:
1195+
if self._focal_length == np.inf:
11961196
self._zmargin = rcParams['axes.zmargin']
11971197
else:
11981198
self._zmargin = 0.

0 commit comments

Comments
 (0)