@@ -918,77 +918,79 @@ class EllipseCollection(Collection):
918918 def __init__ (self , widths , heights , angles , units = 'points' , ** kwargs ):
919919 """
920920 *widths*: sequence
921- half- lengths of first axes (e.g., semi- major axis lengths)
921+ lengths of first axes (e.g., major axis lengths)
922922
923923 *heights*: sequence
924- half- lengths of second axes
924+ lengths of second axes
925925
926926 *angles*: sequence
927927 angles of first axes, degrees CCW from the X-axis
928928
929- *units*: ['points' | 'inches' | 'dots' | 'width' | 'height' | 'x' | 'y']
929+ *units*: ['points' | 'inches' | 'dots' | 'width' | 'height'
930+ | 'x' | 'y' | 'xy']
930931 units in which majors and minors are given; 'width' and 'height'
931932 refer to the dimensions of the axes, while 'x' and 'y'
932- refer to the *offsets* data units.
933+ refer to the *offsets* data units. 'xy' differs from all
934+ others in that the angle as plotted varies with the
935+ aspect ratio, and equals the specified angle only when
936+ the aspect ratio is unity. Hence it behaves the same
937+ as the :class:`~matplotlib.patches.Ellipse` with
938+ axes.transData as its transform.
933939
934940 Additional kwargs inherited from the base :class:`Collection`:
935941
936942 %(Collection)s
937943 """
938944 Collection .__init__ (self ,** kwargs )
939- self ._widths = np .asarray (widths ).ravel ()
940- self ._heights = np .asarray (heights ).ravel ()
945+ self ._widths = 0.5 * np .asarray (widths ).ravel ()
946+ self ._heights = 0.5 * np .asarray (heights ).ravel ()
941947 self ._angles = np .asarray (angles ).ravel () * (np .pi / 180.0 )
942948 self ._units = units
943949 self .set_transform (transforms .IdentityTransform ())
944950 self ._transforms = []
945951 self ._paths = [mpath .Path .unit_circle ()]
946- self ._initialized = False
947952
948-
949- def _init (self ):
950- def on_dpi_change (fig ):
951- self ._transforms = []
952- self .figure .callbacks .connect ('dpi_changed' , on_dpi_change )
953- self ._initialized = True
954-
955- def set_transforms (self ):
956- if not self ._initialized :
957- self ._init ()
953+ def _set_transforms (self ):
954+ """
955+ Calculate transforms immediately before drawing.
956+ """
958957 self ._transforms = []
959958 ax = self .axes
960959 fig = self .figure
961- if self ._units in ('x' , 'y' ):
962- if self ._units == 'x' :
963- dx0 = ax .viewLim .width
964- dx1 = ax .bbox .width
965- else :
966- dx0 = ax .viewLim .height
967- dx1 = ax .bbox .height
968- sc = dx1 / dx0
960+
961+ if self ._units == 'xy' :
962+ sc = 1
963+ elif self ._units == 'x' :
964+ sc = ax .bbox .width / ax .viewLim .width
965+ elif self ._units == 'y' :
966+ sc = ax .bbox .height / ax .viewLim .height
967+ elif self ._units == 'inches' :
968+ sc = fig .dpi
969+ elif self ._units == 'points' :
970+ sc = fig .dpi / 72.0
971+ elif self ._units == 'width' :
972+ sc = ax .bbox .width
973+ elif self ._units == 'height' :
974+ sc = ax .bbox .height
975+ elif self ._units == 'dots' :
976+ sc = 1.0
969977 else :
970- if self ._units == 'inches' :
971- sc = fig .dpi
972- elif self ._units == 'points' :
973- sc = fig .dpi / 72.0
974- elif self ._units == 'width' :
975- sc = ax .bbox .width
976- elif self ._units == 'height' :
977- sc = ax .bbox .height
978- elif self ._units == 'dots' :
979- sc = 1.0
980- else :
981- raise ValueError ('unrecognized units: %s' % self ._units )
978+ raise ValueError ('unrecognized units: %s' % self ._units )
982979
983980 _affine = transforms .Affine2D
984981 for x , y , a in zip (self ._widths , self ._heights , self ._angles ):
985982 trans = _affine ().scale (x * sc , y * sc ).rotate (a )
986983 self ._transforms .append (trans )
987984
985+ if self ._units == 'xy' :
986+ m = ax .transData .get_affine ().get_matrix ().copy ()
987+ m [:2 , 2 :] = 0
988+ self .set_transform (_affine (m ))
989+
990+
988991 def draw (self , renderer ):
989- if True : ###not self._transforms:
990- self .set_transforms ()
991- return Collection .draw (self , renderer )
992+ self ._set_transforms ()
993+ Collection .draw (self , renderer )
992994
993995class PatchCollection (Collection ):
994996 """
0 commit comments