There seems to be a bug in the “transform” argument for CircleCollection, EllipseCollection, and RegularPolyCollection. These classes override any transform passed on instantiation and uses the IdentityTransform instead.
Take, for example, the init method CircleCollection:
def init(self, sizes, **kwargs):
Gives the area of the circle in points^2
%(Collection)s """ Collection.__init__(self,**kwargs) self._sizes = sizes self.set_transform(transforms.IdentityTransform()) self._paths = [mpath.Path.unit_circle()]
If “transform” is passed as a kwarg, it gets updated by the call to
Collection.__init__ (this update is done in Artist, which is a parent class of Collection). But a couple lines after that, the transform is manually reset to the IdentityTransform. Is this a bug?
As it stands, setting the transform kwarg does nothing (and doesn’t complain), so I have to call the set_transform method after creating the collection (not a big deal, but it’s confusing that the first option doesn’t work).
A couple of notes:
- Artist already defaults to setting Artist._transform (and hence Collection._transform) to the IdentityTransform.
- Nevertheless, the set_transform line above is not a do-nothing line: not only does set_transform set the _transform attribute, it also sets the _transformSet attribute.
A few solutions:
- Replace the set_transform line with
self._transformSet = True. (preserves current behavior, without overriding a user-prescribed transform)
- Replace transform passed to self.set_transform with self.get_transform. (same behavior as above.)
- Just remove the set_transform line. This changes the behavior since self._transformSet is left False, but I’m not sure what the correct behavior is.