@@ -1046,22 +1046,20 @@ def set_proj_type(self, proj_type, focal_length=None):
10461046 The focal length can be computed from a desired Field Of View via
10471047 the equation: focal_length = 1/tan(FOV/2)
10481048 """
1049+ _api .check_in_list (['persp' , 'ortho' ], proj_type = proj_type )
10491050 if proj_type == 'persp' :
10501051 if focal_length is None :
1051- self .focal_length = 1
1052+ self ._focal_length = 1
10521053 else :
10531054 if focal_length <= 0 :
1054- raise ValueError (f"focal_length = { focal_length } must be" +
1055+ raise ValueError (f"focal_length = { focal_length } must be"
10551056 " greater than 0" )
1056- self .focal_length = focal_length
1057+ self ._focal_length = focal_length
10571058 elif proj_type == 'ortho' :
10581059 if focal_length not in (None , np .inf ):
1059- raise ValueError (f"focal_length = { focal_length } must be" +
1060+ raise ValueError (f"focal_length = { focal_length } must be"
10601061 f"None for proj_type = { proj_type } " )
1061- self .focal_length = np .inf
1062- else :
1063- raise ValueError (f"proj_type = { proj_type } must be in" +
1064- f"{ 'persp' , 'ortho' } " )
1062+ self ._focal_length = np .inf
10651063
10661064 def _roll_to_vertical (self , arr ):
10671065 """Roll arrays to match the different vertical axis."""
@@ -1118,18 +1116,18 @@ def get_proj(self):
11181116 V [self ._vertical_axis ] = - 1 if abs (elev_rad ) > 0.5 * np .pi else 1
11191117
11201118 # Generate the view and projection transformation matrices
1121- if self .focal_length == np .inf :
1119+ if self ._focal_length == np .inf :
11221120 # Orthographic projection
11231121 viewM = proj3d .view_transformation (eye , R , V , roll_rad )
11241122 projM = proj3d .ortho_transformation (- self .dist , self .dist )
11251123 else :
11261124 # Perspective projection
11271125 # Scale the eye dist to compensate for the focal length zoom effect
1128- eye_focal = R + self .dist * ps * self .focal_length
1126+ eye_focal = R + self .dist * ps * self ._focal_length
11291127 viewM = proj3d .view_transformation (eye_focal , R , V , roll_rad )
11301128 projM = proj3d .persp_transformation (- self .dist ,
11311129 self .dist ,
1132- self .focal_length )
1130+ self ._focal_length )
11331131
11341132 # Combine all the transformation matrices to get the final projection
11351133 M0 = np .dot (viewM , worldM )
@@ -1194,7 +1192,7 @@ def cla(self):
11941192 pass
11951193
11961194 self ._autoscaleZon = True
1197- if self .focal_length == np .inf :
1195+ if self ._focal_length == np .inf :
11981196 self ._zmargin = rcParams ['axes.zmargin' ]
11991197 else :
12001198 self ._zmargin = 0.
0 commit comments