@@ -91,6 +91,11 @@ def __init__(
9191 self .zz_viewLim = Bbox .unit ()
9292 self .xy_dataLim = Bbox .unit ()
9393 self .zz_dataLim = Bbox .unit ()
94+ if 'pb_aspect' in kwargs :
95+ self .pb_aspect = np .asarray (kwargs ['pb_aspect' ])
96+ else :
97+ # chosen for similarity with the previous initial view
98+ self .pb_aspect = np .array ([4 , 4 , 3 ]) / 3.5
9499 # inhibit autoscale_view until the axes are defined
95100 # they can't be defined until Axes.__init__ has been called
96101 self .view_init (self .initial_elev , self .initial_azim )
@@ -342,6 +347,9 @@ def set_anchor(self, anchor, share=False):
342347 ax ._anchor = anchor
343348 ax .stale = True
344349
350+ def set_pb_aspect (self , pb_aspect , zoom = 1 ):
351+ self .pb_aspect = pb_aspect * 1.8 * zoom / proj3d .mod (pb_aspect )
352+
345353 def apply_aspect (self , position = None ):
346354 if position is None :
347355 position = self .get_position (original = True )
@@ -966,7 +974,12 @@ def set_proj_type(self, proj_type):
966974 def get_proj (self ):
967975 """Create the projection matrix from the current viewing position."""
968976 # chosen for similarity with the initial view before gh-8896
969- pb_aspect = np .array ([4 , 4 , 3 ]) / 3.5
977+
978+ # elev stores the elevation angle in the z plane
979+ # azim stores the azimuth angle in the x,y plane
980+ #
981+ # dist is the distance of the eye viewing point from the object
982+ # point.
970983
971984 relev , razim = np .pi * self .elev / 180 , np .pi * self .azim / 180
972985
@@ -977,10 +990,10 @@ def get_proj(self):
977990 # transform to uniform world coordinates 0-1, 0-1, 0-1
978991 worldM = proj3d .world_transformation (xmin , xmax ,
979992 ymin , ymax ,
980- zmin , zmax , pb_aspect = pb_aspect )
993+ zmin , zmax , pb_aspect = self . pb_aspect )
981994
982995 # look into the middle of the new coordinates
983- R = pb_aspect / 2
996+ R = self . pb_aspect / 2
984997
985998 xp = R [0 ] + np .cos (razim ) * np .cos (relev ) * self .dist
986999 yp = R [1 ] + np .sin (razim ) * np .cos (relev ) * self .dist
0 commit comments