@@ -237,16 +237,16 @@ class Line2D(Artist):
237
237
def __str__ (self ):
238
238
if self ._label != "" :
239
239
return "Line2D(%s)" % (self ._label )
240
- elif hasattr (self , '_x' ) and len (self ._x ) > 3 :
240
+ elif self ._x is None :
241
+ return "Line2D()"
242
+ elif len (self ._x ) > 3 :
241
243
return "Line2D((%g,%g),(%g,%g),...,(%g,%g))" \
242
244
% (self ._x [0 ], self ._y [0 ], self ._x [0 ],
243
245
self ._y [0 ], self ._x [- 1 ], self ._y [- 1 ])
244
- elif hasattr ( self , '_x' ) :
246
+ else :
245
247
return "Line2D(%s)" \
246
248
% ("," .join (["(%g,%g)" % (x , y ) for x , y
247
249
in zip (self ._x , self ._y )]))
248
- else :
249
- return "Line2D()"
250
250
251
251
def __init__ (self , xdata , ydata ,
252
252
linewidth = None , # all Nones default to rc
@@ -653,7 +653,7 @@ def recache(self, always=False):
653
653
else :
654
654
self ._x_filled = self ._x
655
655
656
- if hasattr ( self , ' _path' ) :
656
+ if self . _path is not None :
657
657
interpolation_steps = self ._path ._interpolation_steps
658
658
else :
659
659
interpolation_steps = 1
@@ -1449,7 +1449,7 @@ def __init__(self, line):
1449
1449
:class:`matplotlib.axes.Axes` instance and should have the
1450
1450
picker property set.
1451
1451
"""
1452
- if not hasattr ( line , ' axes' ) :
1452
+ if line . axes is None :
1453
1453
raise RuntimeError ('You must first add the line to the Axes' )
1454
1454
1455
1455
if line .get_picker () is None :
0 commit comments