@@ -143,15 +143,15 @@ def __init__(self,
143
143
self .set_offset_position (offset_position )
144
144
self .set_zorder (zorder )
145
145
146
+ self ._offsets = np .zeros ((1 , 2 ))
146
147
self ._uniform_offsets = None
147
- self ._offsets = np .array ([[0 , 0 ]], float )
148
148
if offsets is not None :
149
- offsets = np .asanyarray (offsets , float )
150
149
if transOffset is not None :
151
- self ._offsets = offsets
152
150
self ._transOffset = transOffset
153
151
else :
154
- self ._uniform_offsets = offsets
152
+ # Just a placeholder to trigger the right path in set_offsets.
153
+ self ._uniform_offsets = object ()
154
+ self .set_offsets (offsets )
155
155
156
156
self ._path_effects = None
157
157
self .update (kwargs )
@@ -400,7 +400,7 @@ def set_hatch(self, hatch):
400
400
self .stale = True
401
401
402
402
def get_hatch (self ):
403
- ' Return the current hatching pattern'
403
+ """ Return the current hatching pattern."""
404
404
return self ._hatch
405
405
406
406
def set_offsets (self , offsets ):
@@ -411,18 +411,18 @@ def set_offsets(self, offsets):
411
411
ACCEPTS: float or sequence of floats
412
412
"""
413
413
offsets = np .asanyarray (offsets , float )
414
- #This decision is based on how they are initialized above
414
+ if offsets .shape == (2 ,): # Broadcast (2,) -> (1, 2) but nothing else.
415
+ offsets = offsets [None , :]
416
+ # This decision is based on how they are initialized above in __init__.
415
417
if self ._uniform_offsets is None :
416
418
self ._offsets = offsets
417
419
else :
418
420
self ._uniform_offsets = offsets
419
421
self .stale = True
420
422
421
423
def get_offsets (self ):
422
- """
423
- Return the offsets for the collection.
424
- """
425
- #This decision is based on how they are initialized above in __init__()
424
+ """Return the offsets for the collection."""
425
+ # This decision is based on how they are initialized above in __init__.
426
426
if self ._uniform_offsets is None :
427
427
return self ._offsets
428
428
else :
0 commit comments