@@ -91,6 +91,11 @@ def __init__(
91
91
self .zz_viewLim = Bbox .unit ()
92
92
self .xy_dataLim = Bbox .unit ()
93
93
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
94
99
# inhibit autoscale_view until the axes are defined
95
100
# they can't be defined until Axes.__init__ has been called
96
101
self .view_init (self .initial_elev , self .initial_azim )
@@ -348,6 +353,9 @@ def set_anchor(self, anchor, share=False):
348
353
ax ._anchor = anchor
349
354
ax .stale = True
350
355
356
+ def set_pb_aspect (self , pb_aspect , zoom = 1 ):
357
+ self .pb_aspect = pb_aspect * 1.8 * zoom / proj3d .mod (pb_aspect )
358
+
351
359
def apply_aspect (self , position = None ):
352
360
if position is None :
353
361
position = self .get_position (original = True )
@@ -974,7 +982,12 @@ def set_proj_type(self, proj_type):
974
982
def get_proj (self ):
975
983
"""Create the projection matrix from the current viewing position."""
976
984
# chosen for similarity with the initial view before gh-8896
977
- pb_aspect = np .array ([4 , 4 , 3 ]) / 3.5
985
+
986
+ # elev stores the elevation angle in the z plane
987
+ # azim stores the azimuth angle in the x,y plane
988
+ #
989
+ # dist is the distance of the eye viewing point from the object
990
+ # point.
978
991
979
992
relev , razim = np .pi * self .elev / 180 , np .pi * self .azim / 180
980
993
@@ -985,10 +998,10 @@ def get_proj(self):
985
998
# transform to uniform world coordinates 0-1, 0-1, 0-1
986
999
worldM = proj3d .world_transformation (xmin , xmax ,
987
1000
ymin , ymax ,
988
- zmin , zmax , pb_aspect = pb_aspect )
1001
+ zmin , zmax , pb_aspect = self . pb_aspect )
989
1002
990
1003
# look into the middle of the new coordinates
991
- R = pb_aspect / 2
1004
+ R = self . pb_aspect / 2
992
1005
993
1006
xp = R [0 ] + np .cos (razim ) * np .cos (relev ) * self .dist
994
1007
yp = R [1 ] + np .sin (razim ) * np .cos (relev ) * self .dist
0 commit comments