@@ -143,10 +143,13 @@ 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
149
offsets = np .asanyarray (offsets , float )
150
+ # Broadcast (2,) -> (1, 2) but nothing else.
151
+ if offsets .shape == (2 ,):
152
+ offsets = offsets [None , :]
150
153
if transOffset is not None :
151
154
self ._offsets = offsets
152
155
self ._transOffset = transOffset
@@ -400,7 +403,7 @@ def set_hatch(self, hatch):
400
403
self .stale = True
401
404
402
405
def get_hatch (self ):
403
- ' Return the current hatching pattern'
406
+ """ Return the current hatching pattern."""
404
407
return self ._hatch
405
408
406
409
def set_offsets (self , offsets ):
@@ -411,18 +414,18 @@ def set_offsets(self, offsets):
411
414
ACCEPTS: float or sequence of floats
412
415
"""
413
416
offsets = np .asanyarray (offsets , float )
414
- #This decision is based on how they are initialized above
417
+ if offsets .shape == (2 ,): # Broadcast (2,) -> (1, 2) but nothing else.
418
+ offsets = offsets [None , :]
419
+ # This decision is based on how they are initialized above in __init__.
415
420
if self ._uniform_offsets is None :
416
421
self ._offsets = offsets
417
422
else :
418
423
self ._uniform_offsets = offsets
419
424
self .stale = True
420
425
421
426
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__()
427
+ """Return the offsets for the collection."""
428
+ # This decision is based on how they are initialized above in __init__.
426
429
if self ._uniform_offsets is None :
427
430
return self ._offsets
428
431
else :
0 commit comments