Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c379aae

Browse files
committed
fixed a bug where annotations w/ arrows were not getting the figure instance set properly
svn path=/trunk/matplotlib/; revision=4913
1 parent 24ceac9 commit c379aae

4 files changed

Lines changed: 25 additions & 10 deletions

File tree

lib/matplotlib/lines.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,14 @@ class Line2D(Artist):
169169
def __str__(self):
170170
if self._label != "":
171171
return "Line2D(%s)"%(self._label)
172-
elif len(self._x) > 3:
172+
elif hasattr(self, '_x') and len(self._x) > 3:
173173
return "Line2D((%g,%g),(%g,%g),...,(%g,%g))"\
174174
%(self._x[0],self._y[0],self._x[0],self._y[0],self._x[-1],self._y[-1])
175-
else:
175+
elif hasattr(self, '_x'):
176176
return "Line2D(%s)"\
177177
%(",".join(["(%g,%g)"%(x,y) for x,y in zip(self._x,self._y)]))
178+
else:
179+
return "Line2D()"
178180

179181
def __init__(self, xdata, ydata,
180182
linewidth = None, # all Nones default to rc

lib/matplotlib/mlab.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"""
8585

8686
from __future__ import division
87-
import csv, warnings
87+
import csv, warnings, copy
8888

8989
import numpy as npy
9090

@@ -2186,7 +2186,12 @@ def get_converters(reader):
21862186
# Get header and remove invalid characters
21872187
needheader = names is None
21882188
if needheader:
2189-
headers = reader.next()
2189+
for row in reader:
2190+
if len(row) and row[0].startswith(comments):
2191+
continue
2192+
headers = row
2193+
break
2194+
21902195
# remove these chars
21912196
delete = set("""~!@#$%^&*()-=+~\|]}[{';: /?.>,<""")
21922197
delete.add('"')

lib/matplotlib/rcsetup.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,12 @@ def __call__(self, s):
425425
'figure.facecolor' : [ '0.75', validate_color], # facecolor; scalar gray
426426
'figure.edgecolor' : [ 'w', validate_color], # edgecolor; white
427427

428-
'figure.subplot.left' : [0.125, ValidateInterval(0, 1, closedmin=False, closedmax=False)],
429-
'figure.subplot.right' : [0.9, ValidateInterval(0, 1, closedmin=False, closedmax=False)],
430-
'figure.subplot.bottom' : [0.1, ValidateInterval(0, 1, closedmin=False, closedmax=False)],
431-
'figure.subplot.top' : [0.9, ValidateInterval(0, 1, closedmin=False, closedmax=False)],
432-
'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1, closedmin=False, closedmax=True)],
433-
'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1, closedmin=False, closedmax=True)],
428+
'figure.subplot.left' : [0.125, ValidateInterval(0, 1, closedmin=True, closedmax=True)],
429+
'figure.subplot.right' : [0.9, ValidateInterval(0, 1, closedmin=True, closedmax=True)],
430+
'figure.subplot.bottom' : [0.1, ValidateInterval(0, 1, closedmin=True, closedmax=True)],
431+
'figure.subplot.top' : [0.9, ValidateInterval(0, 1, closedmin=True, closedmax=True)],
432+
'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1, closedmin=True, closedmax=False)],
433+
'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1, closedmin=True, closedmax=False)],
434434

435435
'figure.autolayout' : [False, validate_bool],
436436

lib/matplotlib/text.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,12 @@ def contains(self,event):
10521052
return t,tinfo
10531053

10541054

1055+
def set_figure(self, fig):
1056+
1057+
if self.arrow is not None:
1058+
self.arrow.set_figure(fig)
1059+
Artist.set_figure(self, fig)
1060+
10551061
def set_clip_box(self, clipbox):
10561062
"""
10571063
Set the artist's clip Bbox
@@ -1204,6 +1210,8 @@ def draw(self, renderer):
12041210
self.update_positions(renderer)
12051211

12061212
if self.arrow is not None:
1213+
if self.arrow.figure is None and self.figure is not None:
1214+
self.arrow.figure = self.figure
12071215
self.arrow.draw(renderer)
12081216

12091217
Text.draw(self, renderer)

0 commit comments

Comments
 (0)