Skip to content
This repository

PEP8-compliance on axes.py (patch 1 / 4) #1464

Merged
merged 1 commit into from over 1 year ago

2 participants

Varoquaux Phil Elson
Varoquaux
Collaborator

Here is the first patch on pep8 compliance of the axes.py module.

Cheers,
N

Phil Elson pelson commented on the diff November 08, 2012
lib/matplotlib/axes.py
@@ -968,10 +976,6 @@ def cla(self):
968 976
         self._shared_x_axes.clean()
969 977
         self._shared_y_axes.clean()
970 978
 
971  
-    def get_frame(self):
972  
-        raise AttributeError('Axes.frame was removed in favor of Axes.spines')
2
Phil Elson Collaborator
pelson added a note November 08, 2012

I agree with this change. Just want to point it out to others.

Varoquaux Collaborator
NelleV added a note November 08, 2012

For information, this method was defined twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Phil Elson pelson commented on the diff November 08, 2012
lib/matplotlib/axes.py
@@ -3226,6 +3236,7 @@ def dist(a):
3226 3236
 
3227 3237
         artists = self.lines + self.patches + self.texts
3228 3238
         if callable(among):
  3239
+            # FIXME test is not defined
2
Phil Elson Collaborator
pelson added a note November 08, 2012

Would you mind opening a bug for this one?

Varoquaux Collaborator
NelleV added a note November 08, 2012

I've opened a ticket: #1465

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Phil Elson pelson commented on the diff November 08, 2012
lib/matplotlib/axes.py
@@ -6089,9 +6092,6 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
6089 6092
                 '''replace "faceted=False" with "edgecolors='none'"''',
6090 6093
                 DeprecationWarning)   #2008/04/18
6091 6094
 
6092  
-        sym = None
1
Phil Elson Collaborator
pelson added a note November 08, 2012

Yep. This is good. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Phil Elson pelson commented on the diff November 08, 2012
lib/matplotlib/axes.py
@@ -8825,7 +8822,6 @@ def get_tightbbox(self, renderer, call_axes_locator=True):
8825 8822
         compared to the axes bbox.
8826 8823
         """
8827 8824
 
8828  
-        artists = []
1
Phil Elson Collaborator
pelson added a note November 08, 2012

cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Phil Elson
Collaborator

:+1:

Phil Elson pelson merged commit 3a9a782 into from November 08, 2012
Phil Elson pelson closed this November 08, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 08, 2012
Varoquaux PEP8-compliance on axes.py (patch 1 / 4) 37491c7
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 198 additions and 201 deletions. Show diff stats Hide diff stats

  1. 399  lib/matplotlib/axes.py
399  lib/matplotlib/axes.py
... ...
@@ -1,5 +1,6 @@
1 1
 from __future__ import division, print_function
2  
-import math, sys, warnings, datetime
  2
+import math
  3
+import warnings
3 4
 from operator import itemgetter
4 5
 import itertools
5 6
 
@@ -16,7 +17,7 @@
16 17
 import matplotlib.collections as mcoll
17 18
 import matplotlib.colors as mcolors
18 19
 import matplotlib.contour as mcontour
19  
-import matplotlib.dates as _ # <-registers a date unit converter
  20
+import matplotlib.dates as _  # <-registers a date unit converter
20 21
 from matplotlib import docstring
21 22
 import matplotlib.font_manager as font_manager
22 23
 import matplotlib.image as mimage
@@ -42,6 +43,7 @@
42 43
 is_string_like = cbook.is_string_like
43 44
 is_sequence_of_strings = cbook.is_sequence_of_strings
44 45
 
  46
+
45 47
 def _string_to_bool(s):
46 48
     if not is_string_like(s):
47 49
         return s
@@ -51,6 +53,7 @@ def _string_to_bool(s):
51 53
         return False
52 54
     raise ValueError("string argument must be either 'on' or 'off'")
53 55
 
  56
+
54 57
 def _process_plot_format(fmt):
55 58
     """
56 59
     Process a MATLAB style color/line style format string.  Return a
@@ -80,26 +83,26 @@ def _process_plot_format(fmt):
80 83
         try:
81 84
             fmtint = str(int(fmt))
82 85
         except ValueError:
83  
-            return linestyle, marker, color         # Yes
  86
+            return linestyle, marker, color  # Yes
84 87
         else:
85 88
             if fmt != fmtint:
86 89
                 # user definitely doesn't want tri_down marker
87  
-                return linestyle, marker, color     # Yes
  90
+                return linestyle, marker, color  # Yes
88 91
             else:
89 92
                 # ignore converted color
90 93
                 color = None
91 94
     except ValueError:
92  
-        pass                                        # No, not just a color.
  95
+        pass  # No, not just a color.
93 96
 
94 97
     # handle the multi char special cases and strip them from the
95 98
     # string
96  
-    if fmt.find('--')>=0:
  99
+    if fmt.find('--') >= 0:
97 100
         linestyle = '--'
98 101
         fmt = fmt.replace('--', '')
99  
-    if fmt.find('-.')>=0:
  102
+    if fmt.find('-.') >= 0:
100 103
         linestyle = '-.'
101 104
         fmt = fmt.replace('-.', '')
102  
-    if fmt.find(' ')>=0:
  105
+    if fmt.find(' ') >= 0:
103 106
         linestyle = 'None'
104 107
         fmt = fmt.replace(' ', '')
105 108
 
@@ -134,6 +137,7 @@ def _process_plot_format(fmt):
134 137
 
135 138
     return linestyle, marker, color
136 139
 
  140
+
137 141
 def set_default_color_cycle(clist):
138 142
     """
139 143
     Change the default cycle of colors that will be used by the plot
@@ -187,36 +191,41 @@ def set_color_cycle(self, clist=None):
187 191
     def __call__(self, *args, **kwargs):
188 192
 
189 193
         if self.axes.xaxis is not None and self.axes.yaxis is not None:
190  
-            xunits = kwargs.pop( 'xunits', self.axes.xaxis.units)
  194
+            xunits = kwargs.pop('xunits', self.axes.xaxis.units)
  195
+
191 196
             if self.axes.name == 'polar':
192  
-                xunits = kwargs.pop( 'thetaunits', xunits )
193  
-            yunits = kwargs.pop( 'yunits', self.axes.yaxis.units)
  197
+                xunits = kwargs.pop('thetaunits', xunits)
  198
+
  199
+            yunits = kwargs.pop('yunits', self.axes.yaxis.units)
  200
+
194 201
             if self.axes.name == 'polar':
195  
-                yunits = kwargs.pop( 'runits', yunits )
196  
-            if xunits!=self.axes.xaxis.units:
  202
+                yunits = kwargs.pop('runits', yunits)
  203
+
  204
+            if xunits != self.axes.xaxis.units:
197 205
                 self.axes.xaxis.set_units(xunits)
198  
-            if yunits!=self.axes.yaxis.units:
  206
+
  207
+            if yunits != self.axes.yaxis.units:
199 208
                 self.axes.yaxis.set_units(yunits)
200 209
 
201  
-        ret =  self._grab_next_args(*args, **kwargs)
  210
+        ret = self._grab_next_args(*args, **kwargs)
202 211
         return ret
203 212
 
204 213
     def set_lineprops(self, line, **kwargs):
205 214
         assert self.command == 'plot', 'set_lineprops only works with "plot"'
206 215
         for key, val in kwargs.items():
207  
-            funcName = "set_%s"%key
208  
-            if not hasattr(line,funcName):
209  
-                raise TypeError('There is no line property "%s"'%key)
210  
-            func = getattr(line,funcName)
  216
+            funcName = "set_%s" % key
  217
+            if not hasattr(line, funcName):
  218
+                raise TypeError('There is no line property "%s"' % key)
  219
+            func = getattr(line, funcName)
211 220
             func(val)
212 221
 
213 222
     def set_patchprops(self, fill_poly, **kwargs):
214 223
         assert self.command == 'fill', 'set_patchprops only works with "fill"'
215 224
         for key, val in kwargs.items():
216  
-            funcName = "set_%s"%key
217  
-            if not hasattr(fill_poly,funcName):
218  
-                raise TypeError('There is no patch property "%s"'%key)
219  
-            func = getattr(fill_poly,funcName)
  225
+            funcName = "set_%s" % key
  226
+            if not hasattr(fill_poly, funcName):
  227
+                raise TypeError('There is no patch property "%s"' % key)
  228
+            func = getattr(fill_poly, funcName)
220 229
             func(val)
221 230
 
222 231
     def _xy_from_xy(self, x, y):
@@ -224,7 +233,7 @@ def _xy_from_xy(self, x, y):
224 233
             bx = self.axes.xaxis.update_units(x)
225 234
             by = self.axes.yaxis.update_units(y)
226 235
 
227  
-            if self.command!='plot':
  236
+            if self.command != 'plot':
228 237
                 # the Line2D class can handle unitized data, with
229 238
                 # support for post hoc unit changes etc.  Other mpl
230 239
                 # artists, eg Polygon which _process_plot_var_args
@@ -242,7 +251,7 @@ def _xy_from_xy(self, x, y):
242 251
                 if by:
243 252
                     y = self.axes.convert_yunits(y)
244 253
 
245  
-        x = np.atleast_1d(x) #like asanyarray, but converts scalar to array
  254
+        x = np.atleast_1d(x)  # like asanyarray, but converts scalar to array
246 255
         y = np.atleast_1d(y)
247 256
         if x.shape[0] != y.shape[0]:
248 257
             raise ValueError("x and y must have same first dimension")
@@ -250,13 +259,13 @@ def _xy_from_xy(self, x, y):
250 259
             raise ValueError("x and y can be no greater than 2-D")
251 260
 
252 261
         if x.ndim == 1:
253  
-            x = x[:,np.newaxis]
  262
+            x = x[:, np.newaxis]
254 263
         if y.ndim == 1:
255  
-            y = y[:,np.newaxis]
  264
+            y = y[:, np.newaxis]
256 265
         return x, y
257 266
 
258 267
     def _makeline(self, x, y, kw, kwargs):
259  
-        kw = kw.copy() # Don't modify the original kw.
  268
+        kw = kw.copy()  # Don't modify the original kw.
260 269
         if not 'color' in kw and not 'color' in kwargs.keys():
261 270
             kw['color'] = self.color_cycle.next()
262 271
             # (can't use setdefault because it always evaluates
@@ -274,15 +283,14 @@ def _makefill(self, x, y, kw, kwargs):
274 283
         except KeyError:
275 284
             facecolor = self.color_cycle.next()
276 285
         seg = mpatches.Polygon(np.hstack(
277  
-                                (x[:,np.newaxis],y[:,np.newaxis])),
278  
-                      facecolor = facecolor,
  286
+                                (x[:, np.newaxis], y[:, np.newaxis])),
  287
+                      facecolor=facecolor,
279 288
                       fill=True,
280 289
                       closed=kw['closed']
281 290
                       )
282 291
         self.set_patchprops(seg, **kwargs)
283 292
         return seg
284 293
 
285  
-
286 294
     def _plot_args(self, tup, kwargs):
287 295
         ret = []
288 296
         if len(tup) > 1 and is_string_like(tup[-1]):
@@ -315,7 +323,7 @@ def _plot_args(self, tup, kwargs):
315 323
 
316 324
         ncx, ncy = x.shape[1], y.shape[1]
317 325
         for j in xrange(max(ncx, ncy)):
318  
-            seg = func(x[:,j%ncx], y[:,j%ncy], kw, kwargs)
  326
+            seg = func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)
319 327
             ret.append(seg)
320 328
         return ret
321 329
 
@@ -324,7 +332,7 @@ def _grab_next_args(self, *args, **kwargs):
324 332
         remaining = args
325 333
         while 1:
326 334
 
327  
-            if len(remaining)==0:
  335
+            if len(remaining) == 0:
328 336
                 return
329 337
             if len(remaining) <= 3:
330 338
                 for seg in self._plot_args(remaining, kwargs):
@@ -338,7 +346,7 @@ def _grab_next_args(self, *args, **kwargs):
338 346
 
339 347
             for seg in self._plot_args(remaining[:isplit], kwargs):
340 348
                 yield seg
341  
-            remaining=remaining[isplit:]
  349
+            remaining = remaining[isplit:]
342 350
 
343 351
 
344 352
 class Axes(martist.Artist):
@@ -364,10 +372,10 @@ def __str__(self):
364 372
         return "Axes(%g,%g;%gx%g)" % tuple(self._position.bounds)
365 373
 
366 374
     def __init__(self, fig, rect,
367  
-                 axisbg = None, # defaults to rc axes.facecolor
368  
-                 frameon = True,
369  
-                 sharex=None, # use Axes instance's xaxis info
370  
-                 sharey=None, # use Axes instance's yaxis info
  375
+                 axisbg=None,  # defaults to rc axes.facecolor
  376
+                 frameon=True,
  377
+                 sharex=None,  # use Axes instance's xaxis info
  378
+                 sharey=None,  # use Axes instance's yaxis info
371 379
                  label='',
372 380
                  xscale=None,
373 381
                  yscale=None,
@@ -423,7 +431,8 @@ def __init__(self, fig, rect,
423 431
           *yticklabels*      sequence of strings
424 432
           *yticks*           sequence of floats
425 433
           ================   =========================================
426  
-        """ % {'scale': ' | '.join([repr(x) for x in mscale.get_scale_names()])}
  434
+        """ % {'scale': ' | '.join(
  435
+            [repr(x) for x in mscale.get_scale_names()])}
427 436
         martist.Artist.__init__(self)
428 437
         if isinstance(rect, mtransforms.Bbox):
429 438
             self._position = rect
@@ -460,7 +469,8 @@ def __init__(self, fig, rect,
460 469
         # this call may differ for non-sep axes, eg polar
461 470
         self._init_axis()
462 471
 
463  
-        if axisbg is None: axisbg = rcParams['axes.facecolor']
  472
+        if axisbg is None:
  473
+            axisbg = rcParams['axes.facecolor']
464 474
         self._axisbg = axisbg
465 475
         self._frameon = frameon
466 476
         self._axisbelow = rcParams['axes.axisbelow']
@@ -468,26 +478,25 @@ def __init__(self, fig, rect,
468 478
         self._rasterization_zorder = None
469 479
 
470 480
         self._hold = rcParams['axes.hold']
471  
-        self._connected = {} # a dict from events to (id, func)
  481
+        self._connected = {}  # a dict from events to (id, func)
472 482
         self.cla()
473 483
         # funcs used to format x and y - fall back on major formatters
474 484
         self.fmt_xdata = None
475 485
         self.fmt_ydata = None
476 486
 
477  
-
478  
-        self.set_cursor_props((1,'k')) # set the cursor properties for axes
  487
+        self.set_cursor_props((1, 'k'))  # set the cursor properties for axes
479 488
 
480 489
         self._cachedRenderer = None
481 490
         self.set_navigate(True)
482 491
         self.set_navigate_mode(None)
483 492
 
484  
-
485 493
         if xscale:
486 494
             self.set_xscale(xscale)
487 495
         if yscale:
488 496
             self.set_yscale(yscale)
489 497
 
490  
-        if len(kwargs): martist.setp(self, **kwargs)
  498
+        if len(kwargs):
  499
+            martist.setp(self, **kwargs)
491 500
 
492 501
         if self.xaxis is not None:
493 502
             self._xcid = self.xaxis.callbacks.connect('units finalize',
@@ -531,8 +540,9 @@ def set_figure(self, fig):
531 540
         """
532 541
         martist.Artist.set_figure(self, fig)
533 542
 
534  
-        self.bbox = mtransforms.TransformedBbox(self._position, fig.transFigure)
535  
-        #these will be updated later as data is added
  543
+        self.bbox = mtransforms.TransformedBbox(self._position,
  544
+                                                fig.transFigure)
  545
+        # these will be updated later as data is added
536 546
         self.dataLim = mtransforms.Bbox.unit()
537 547
         self.viewLim = mtransforms.Bbox.unit()
538 548
         self.transScale = mtransforms.TransformWrapper(
@@ -580,7 +590,7 @@ def _set_lim_and_transforms(self):
580 590
         self._yaxis_transform = mtransforms.blended_transform_factory(
581 591
                 self.transAxes, self.transData)
582 592
 
583  
-    def get_xaxis_transform(self,which='grid'):
  593
+    def get_xaxis_transform(self, which='grid'):
584 594
         """
585 595
         Get the transformation used for drawing x-axis labels, ticks
586 596
         and gridlines.  The x-direction is in data coordinates and the
@@ -594,12 +604,12 @@ def get_xaxis_transform(self,which='grid'):
594 604
             place axis elements in different locations.
595 605
 
596 606
         """
597  
-        if which=='grid':
  607
+        if which == 'grid':
598 608
             return self._xaxis_transform
599  
-        elif which=='tick1':
  609
+        elif which == 'tick1':
600 610
             # for cartesian projection, this is bottom spine
601 611
             return self.spines['bottom'].get_spine_transform()
602  
-        elif which=='tick2':
  612
+        elif which == 'tick2':
603 613
             # for cartesian projection, this is top spine
604 614
             return self.spines['top'].get_spine_transform()
605 615
         else:
@@ -657,7 +667,7 @@ def get_xaxis_text2_transform(self, pad_points):
657 667
                                               self.figure.dpi_scale_trans),
658 668
                 "bottom", "center")
659 669
 
660  
-    def get_yaxis_transform(self,which='grid'):
  670
+    def get_yaxis_transform(self, which='grid'):
661 671
         """
662 672
         Get the transformation used for drawing y-axis labels, ticks
663 673
         and gridlines.  The x-direction is in axis coordinates and the
@@ -671,12 +681,12 @@ def get_yaxis_transform(self,which='grid'):
671 681
             place axis elements in different locations.
672 682
 
673 683
         """
674  
-        if which=='grid':
  684
+        if which == 'grid':
675 685
             return self._yaxis_transform
676  
-        elif which=='tick1':
  686
+        elif which == 'tick1':
677 687
             # for cartesian projection, this is bottom spine
678 688
             return self.spines['left'].get_spine_transform()
679  
-        elif which=='tick2':
  689
+        elif which == 'tick2':
680 690
             # for cartesian projection, this is top spine
681 691
             return self.spines['right'].get_spine_transform()
682 692
         else:
@@ -752,7 +762,6 @@ def get_position(self, original=False):
752 762
         else:
753 763
             return self._position.frozen()
754 764
 
755  
-
756 765
     def set_position(self, pos, which='both'):
757 766
         """
758 767
         Set the axes position with::
@@ -795,7 +804,7 @@ def set_axes_locator(self, locator):
795 804
         """
796 805
         set axes_locator
797 806
 
798  
-        ACCEPT : a callable object which takes an axes instance and renderer and
  807
+        ACCEPT: a callable object which takes an axes instance and renderer and
799 808
                  returns a bbox.
800 809
         """
801 810
         self._axes_locator = locator
@@ -845,10 +854,10 @@ def _gen_axes_spines(self, locations=None, offset=0.0, units='inches'):
845 854
 
846 855
         """
847 856
         return {
848  
-            'left':mspines.Spine.linear_spine(self,'left'),
849  
-            'right':mspines.Spine.linear_spine(self,'right'),
850  
-            'bottom':mspines.Spine.linear_spine(self,'bottom'),
851  
-            'top':mspines.Spine.linear_spine(self,'top'),
  857
+            'left': mspines.Spine.linear_spine(self, 'left'),
  858
+            'right': mspines.Spine.linear_spine(self, 'right'),
  859
+            'bottom': mspines.Spine.linear_spine(self, 'bottom'),
  860
+            'top': mspines.Spine.linear_spine(self, 'top'),
852 861
             }
853 862
 
854 863
     def cla(self):
@@ -856,7 +865,7 @@ def cla(self):
856 865
         # Note: this is called by Axes.__init__()
857 866
         self.xaxis.cla()
858 867
         self.yaxis.cla()
859  
-        for name,spine in self.spines.iteritems():
  868
+        for name, spine in self.spines.iteritems():
860 869
             spine.cla()
861 870
 
862 871
         self.ignore_existing_data_limits = True
@@ -915,7 +924,7 @@ def cla(self):
915 924
         self._xmargin = 0
916 925
         self._ymargin = 0
917 926
         self._tight = False
918  
-        self._update_transScale()         # needed?
  927
+        self._update_transScale()  # needed?
919 928
 
920 929
         self._get_lines = _process_plot_var_args(self)
921 930
         self._get_patches_for_fill = _process_plot_var_args(self, 'fill')
@@ -927,18 +936,17 @@ def cla(self):
927 936
         self.tables = []
928 937
         self.artists = []
929 938
         self.images = []
930  
-        self._current_image = None # strictly for pyplot via _sci, _gci
  939
+        self._current_image = None  # strictly for pyplot via _sci, _gci
931 940
         self.legend_ = None
932 941
         self.collections = []  # collection.Collection instances
933  
-        self.containers = []  #
  942
+        self.containers = []
934 943
 
935 944
         self.grid(self._gridOn)
936 945
         props = font_manager.FontProperties(size=rcParams['axes.titlesize'])
937 946
 
938  
-
939 947
         self.titleOffsetTrans = mtransforms.ScaledTranslation(
940 948
             0.0, 5.0 / 72.0, self.figure.dpi_scale_trans)
941  
-        self.title =  mtext.Text(
  949
+        self.title = mtext.Text(
942 950
             x=0.5, y=1.0, text='',
943 951
             fontproperties=props,
944 952
             verticalalignment='baseline',
@@ -968,10 +976,6 @@ def cla(self):
968 976
         self._shared_x_axes.clean()
969 977
         self._shared_y_axes.clean()
970 978
 
971  
-    def get_frame(self):
972  
-        raise AttributeError('Axes.frame was removed in favor of Axes.spines')
973  
-    frame = property(get_frame)
974  
-
975 979
     def clear(self):
976 980
         """clear the axes"""
977 981
         self.cla()
@@ -985,7 +989,6 @@ def set_color_cycle(self, clist):
985 989
         self._get_lines.set_color_cycle(clist)
986 990
         self._get_patches_for_fill.set_color_cycle(clist)
987 991
 
988  
-
989 992
     def ishold(self):
990 993
         """return the HOLD status of the axes"""
991 994
         return self._hold
@@ -1010,7 +1013,6 @@ def hold(self, b=None):
1010 1013
           # turn hold off
1011 1014
           hold(False)
1012 1015
 
1013  
-
1014 1016
         When hold is *True*, subsequent plot commands will be added to
1015 1017
         the current axes.  When hold is *False*, the current axes and
1016 1018
         figure will be cleared on the next plot command
@@ -1071,7 +1073,7 @@ def set_aspect(self, aspect, adjustable=None, anchor=None):
1071 1073
         elif aspect == 'equal':
1072 1074
             self._aspect = 'equal'
1073 1075
         else:
1074  
-            self._aspect = float(aspect) # raise ValueError if necessary
  1076
+            self._aspect = float(aspect)  # raise ValueError if necessary
1075 1077
 
1076 1078
         if adjustable is not None:
1077 1079
             self.set_adjustable(adjustable)
@@ -1120,7 +1122,7 @@ def set_anchor(self, anchor):
1120 1122
             self._anchor = anchor
1121 1123
         else:
1122 1124
             raise ValueError('argument must be among %s' %
1123  
-                                ', '.join(mtransforms.Bbox.coefs.keys()))
  1125
+                             ', '.join(mtransforms.Bbox.coefs.keys()))
1124 1126
 
1125 1127
     def get_data_ratio(self):
1126 1128
         """
@@ -1129,28 +1131,26 @@ def get_data_ratio(self):
1129 1131
         This method is intended to be overridden by new projection
1130 1132
         types.
1131 1133
         """
1132  
-        xmin,xmax = self.get_xbound()
1133  
-        ymin,ymax = self.get_ybound()
1134  
-
1135  
-        xsize = max(math.fabs(xmax-xmin), 1e-30)
1136  
-        ysize = max(math.fabs(ymax-ymin), 1e-30)
  1134
+        xmin, xmax = self.get_xbound()
  1135
+        ymin, ymax = self.get_ybound()
1137 1136
 
1138  
-        return ysize/xsize
  1137
+        xsize = max(math.fabs(xmax - xmin), 1e-30)
  1138
+        ysize = max(math.fabs(ymax - ymin), 1e-30)
1139 1139
 
  1140
+        return ysize / xsize
1140 1141
 
1141 1142
     def get_data_ratio_log(self):
1142 1143
         """
1143 1144
         Returns the aspect ratio of the raw data in log scale.
1144 1145
         Will be used when both axis scales are in log.
1145 1146
         """
1146  
-        xmin,xmax = self.get_xbound()
1147  
-        ymin,ymax = self.get_ybound()
1148  
-
1149  
-        xsize = max(math.fabs(math.log10(xmax)-math.log10(xmin)), 1e-30)
1150  
-        ysize = max(math.fabs(math.log10(ymax)-math.log10(ymin)), 1e-30)
  1147
+        xmin, xmax = self.get_xbound()
  1148
+        ymin, ymax = self.get_ybound()
1151 1149
 
1152  
-        return ysize/xsize
  1150
+        xsize = max(math.fabs(math.log10(xmax) - math.log10(xmin)), 1e-30)
  1151
+        ysize = max(math.fabs(math.log10(ymax) - math.log10(ymin)), 1e-30)
1153 1152
 
  1153
+        return ysize / xsize
1154 1154
 
1155 1155
     def apply_aspect(self, position=None):
1156 1156
         """
@@ -1160,7 +1160,6 @@ def apply_aspect(self, position=None):
1160 1160
         if position is None:
1161 1161
             position = self.get_position(original=True)
1162 1162
 
1163  
-
1164 1163
         aspect = self.get_aspect()
1165 1164
 
1166 1165
         if self.name != 'polar':
@@ -1169,20 +1168,20 @@ def apply_aspect(self, position=None):
1169 1168
                 aspect_scale_mode = "linear"
1170 1169
             elif xscale == "log" and yscale == "log":
1171 1170
                 aspect_scale_mode = "log"
1172  
-            elif (xscale == "linear" and yscale == "log") or \
1173  
-                    (xscale == "log" and yscale == "linear"):
  1171
+            elif ((xscale == "linear" and yscale == "log") or
  1172
+                  (xscale == "log" and yscale == "linear")):
1174 1173
                 if aspect is not "auto":
1175 1174
                     warnings.warn(
1176  
-                        'aspect is not supported for Axes with xscale=%s, yscale=%s' \
1177  
-                        % (xscale, yscale))
  1175
+                        'aspect is not supported for Axes with xscale=%s, '
  1176
+                        'yscale=%s' % (xscale, yscale))
1178 1177
                     aspect = "auto"
1179  
-            else: # some custom projections have their own scales.
  1178
+            else:  # some custom projections have their own scales.
1180 1179
                 pass
1181 1180
         else:
1182 1181
             aspect_scale_mode = "linear"
1183 1182
 
1184 1183
         if aspect == 'auto':
1185  
-            self.set_position( position , which='active')
  1184
+            self.set_position(position, which='active')
1186 1185
             return
1187 1186
 
1188 1187
         if aspect == 'equal':
@@ -1198,8 +1197,8 @@ def apply_aspect(self, position=None):
1198 1197
                 warnings.warn(
1199 1198
                     'shared axes: "adjustable" is being changed to "datalim"')
1200 1199
 
1201  
-        figW,figH = self.get_figure().get_size_inches()
1202  
-        fig_aspect = figH/figW
  1200
+        figW, figH = self.get_figure().get_size_inches()
  1201
+        fig_aspect = figH / figW
1203 1202
         if self._adjustable in ['box', 'box-forced']:
1204 1203
             if aspect_scale_mode == "log":
1205 1204
                 box_aspect = A * self.get_data_ratio_log()
@@ -1214,23 +1213,21 @@ def apply_aspect(self, position=None):
1214 1213
         # by prior use of 'box'
1215 1214
         self.set_position(position, which='active')
1216 1215
 
1217  
-
1218  
-        xmin,xmax = self.get_xbound()
1219  
-        ymin,ymax = self.get_ybound()
  1216
+        xmin, xmax = self.get_xbound()
  1217
+        ymin, ymax = self.get_ybound()
1220 1218
 
1221 1219
         if aspect_scale_mode == "log":
1222 1220
             xmin, xmax = math.log10(xmin), math.log10(xmax)
1223 1221
             ymin, ymax = math.log10(ymin), math.log10(ymax)
1224 1222
 
1225  
-        xsize = max(math.fabs(xmax-xmin), 1e-30)
1226  
-        ysize = max(math.fabs(ymax-ymin), 1e-30)
1227  
-
  1223
+        xsize = max(math.fabs(xmax - xmin), 1e-30)
  1224
+        ysize = max(math.fabs(ymax - ymin), 1e-30)
1228 1225
 
1229  
-        l,b,w,h = position.bounds
1230  
-        box_aspect = fig_aspect * (h/w)
  1226
+        l, b, w, h = position.bounds
  1227
+        box_aspect = fig_aspect * (h / w)
1231 1228
         data_ratio = box_aspect / A
1232 1229
 
1233  
-        y_expander = (data_ratio*xsize/ysize - 1.0)
  1230
+        y_expander = (data_ratio * xsize / ysize - 1.0)
1234 1231
         #print 'y_expander', y_expander
1235 1232
         # If y_expander > 0, the dy/dx viewLim ratio needs to increase
1236 1233
         if abs(y_expander) < 0.005:
@@ -1254,7 +1251,8 @@ def apply_aspect(self, position=None):
1254 1251
         Xsize = ysize / data_ratio
1255 1252
         Xmarg = Xsize - xr
1256 1253
         Ymarg = Ysize - yr
1257  
-        xm = 0  # Setting these targets to, e.g., 0.05*xr does not seem to help.
  1254
+        xm = 0  # Setting these targets to, e.g., 0.05*xr does not seem to
  1255
+                # help.
1258 1256
         ym = 0
1259 1257
         #print 'xmin, xmax, ymin, ymax', xmin, xmax, ymin, ymax
1260 1258
         #print 'xsize, Xsize, ysize, Ysize', xsize, Xsize, ysize, Ysize
@@ -1277,23 +1275,23 @@ def apply_aspect(self, position=None):
1277 1275
             else:
1278 1276
                 adjy = y_expander > 0
1279 1277
             #print 'y_expander, adjy', y_expander, adjy
1280  
-            adjust_y = changey or adjy  #(Ymarg > xmarg)
  1278
+            adjust_y = changey or adjy  # (Ymarg > xmarg)
1281 1279
         if adjust_y:
1282  
-            yc = 0.5*(ymin+ymax)
1283  
-            y0 = yc - Ysize/2.0
1284  
-            y1 = yc + Ysize/2.0
  1280
+            yc = 0.5 * (ymin + ymax)
  1281
+            y0 = yc - Ysize / 2.0
  1282
+            y1 = yc + Ysize / 2.0
1285 1283
             if aspect_scale_mode == "log":
1286  
-                self.set_ybound((10.**y0, 10.**y1))
  1284
+                self.set_ybound((10. ** y0, 10. ** y1))
1287 1285
             else:
1288 1286
                 self.set_ybound((y0, y1))
1289 1287
             #print 'New y0, y1:', y0, y1
1290 1288
             #print 'New ysize, ysize/xsize', y1-y0, (y1-y0)/xsize
1291 1289
         else:
1292  
-            xc = 0.5*(xmin+xmax)
1293  
-            x0 = xc - Xsize/2.0
1294  
-            x1 = xc + Xsize/2.0
  1290
+            xc = 0.5 * (xmin + xmax)
  1291
+            x0 = xc - Xsize / 2.0
  1292
+            x1 = xc + Xsize / 2.0
1295 1293
             if aspect_scale_mode == "log":
1296  
-                self.set_xbound((10.**x0, 10.**x1))
  1294
+                self.set_xbound((10. ** x0, 10. ** x1))
1297 1295
             else:
1298 1296
                 self.set_xbound((x0, x1))
1299 1297
             #print 'New x0, x1:', x0, x1
@@ -1313,21 +1311,23 @@ def axis(self, *v, **kwargs):
1313 1311
             ymin, ymax = self.get_ylim()
1314 1312
             return xmin, xmax, ymin, ymax
1315 1313
 
1316  
-        if len(v)==1 and is_string_like(v[0]):
  1314
+        if len(v) == 1 and is_string_like(v[0]):
1317 1315
             s = v[0].lower()
1318  
-            if s=='on': self.set_axis_on()
1319  
-            elif s=='off': self.set_axis_off()
  1316
+            if s == 'on':
  1317
+                self.set_axis_on()
  1318
+            elif s == 'off':
  1319
+                self.set_axis_off()
1320 1320
             elif s in ('equal', 'tight', 'scaled', 'normal', 'auto', 'image'):
1321 1321
                 self.set_autoscale_on(True)
1322 1322
                 self.set_aspect('auto')
1323 1323
                 self.autoscale_view(tight=False)
1324 1324
                 # self.apply_aspect()
1325  
-                if s=='equal':
  1325
+                if s == 'equal':
1326 1326
                     self.set_aspect('equal', adjustable='datalim')
1327 1327
                 elif s == 'scaled':
1328 1328
                     self.set_aspect('equal', adjustable='box', anchor='C')
1329  
-                    self.set_autoscale_on(False) # Req. by Mark Bakker
1330  
-                elif s=='tight':
  1329
+                    self.set_autoscale_on(False)  # Req. by Mark Bakker
  1330
+                elif s == 'tight':
1331 1331
                     self.autoscale_view(tight=True)
1332 1332
                     self.set_autoscale_on(False)
1333 1333
                 elif s == 'image':
@@ -1348,16 +1348,16 @@ def axis(self, *v, **kwargs):
1348 1348
         except IndexError:
1349 1349
             xmin = kwargs.get('xmin', None)
1350 1350
             xmax = kwargs.get('xmax', None)
1351  
-            auto = False # turn off autoscaling, unless...
  1351
+            auto = False  # turn off autoscaling, unless...
1352 1352
             if xmin is None and xmax is None:
1353  
-                auto = None # leave autoscaling state alone
  1353
+                auto = None  # leave autoscaling state alone
1354 1354
             xmin, xmax = self.set_xlim(xmin, xmax, emit=emit, auto=auto)
1355 1355
 
1356 1356
             ymin = kwargs.get('ymin', None)
1357 1357
             ymax = kwargs.get('ymax', None)
1358  
-            auto = False # turn off autoscaling, unless...
  1358
+            auto = False  # turn off autoscaling, unless...
1359 1359
             if ymin is None and ymax is None:
1360  
-                auto = None # leave autoscaling state alone
  1360
+                auto = None  # leave autoscaling state alone
1361 1361
             ymin, ymax = self.set_ylim(ymin, ymax, emit=emit, auto=auto)
1362 1362
             return xmin, xmax, ymin, ymax
1363 1363
 
@@ -1384,7 +1384,9 @@ def get_frame(self):
1384 1384
         return self.patch
1385 1385
 
1386 1386
     def get_legend(self):
1387  
-        """Return the legend.Legend instance, or None if no legend is defined"""
  1387
+        """
  1388
+        Return the legend.Legend instance, or None if no legend is defined
  1389
+        """
1388 1390
         return self.legend_
1389 1391
 
1390 1392
     def get_images(self):
@@ -1401,13 +1403,13 @@ def get_xaxis(self):
1401 1403
 
1402 1404
     def get_xgridlines(self):
1403 1405
         """Get the x grid lines as a list of Line2D instances"""
1404  
-        return cbook.silent_list('Line2D xgridline', self.xaxis.get_gridlines())
1405  
-
  1406
+        return cbook.silent_list('Line2D xgridline',
  1407
+                                 self.xaxis.get_gridlines())
1406 1408
 
1407 1409
     def get_xticklines(self):
1408 1410
         """Get the xtick lines as a list of Line2D instances"""
1409  
-        return cbook.silent_list('Text xtickline', self.xaxis.get_ticklines())
1410  
-
  1411
+        return cbook.silent_list('Text xtickline',
  1412
+                                 self.xaxis.get_ticklines())
1411 1413
 
1412 1414
     def get_yaxis(self):
1413 1415
         """Return the YAxis instance"""
@@ -1415,11 +1417,13 @@ def get_yaxis(self):
1415 1417
 
1416 1418
     def get_ygridlines(self):
1417 1419
         """Get the y grid lines as a list of Line2D instances"""
1418  
-        return cbook.silent_list('Line2D ygridline', self.yaxis.get_gridlines())
  1420
+        return cbook.silent_list('Line2D ygridline',
  1421
+                                 self.yaxis.get_gridlines())
1419 1422
 
1420 1423
     def get_yticklines(self):
1421 1424
         """Get the ytick lines as a list of Line2D instances"""
1422  
-        return cbook.silent_list('Line2D ytickline', self.yaxis.get_ticklines())
  1425
+        return cbook.silent_list('Line2D ytickline',
  1426
+                                 self.yaxis.get_ticklines())
1423 1427
 
1424 1428
     #### Adding and tracking artists
1425 1429
 
@@ -1434,7 +1438,8 @@ def _sci(self, im):
1434 1438
                     "ContourSet must be in current Axes")
1435 1439
         elif im not in self.images and im not in self.collections:
1436 1440
             raise ValueError(
1437  
-            "Argument must be an image, collection, or ContourSet in this Axes")
  1441
+                "Argument must be an image, collection, or ContourSet in "
  1442
+                "this Axes")
1438 1443
         self._current_image = im
1439 1444
 
1440 1445
     def _gci(self):
@@ -1456,7 +1461,7 @@ def has_data(self):
1456 1461
             len(self.collections) +
1457 1462
             len(self.images) +
1458 1463
             len(self.lines) +
1459  
-            len(self.patches))>0
  1464
+            len(self.patches)) > 0
1460 1465
 
1461 1466
     def add_artist(self, a):
1462 1467
         """
@@ -1480,7 +1485,7 @@ def add_collection(self, collection, autolim=True):
1480 1485
         """
1481 1486
         label = collection.get_label()
1482 1487
         if not label:
1483  
-            collection.set_label('_collection%d'%len(self.collections))
  1488
+            collection.set_label('_collection%d' % len(self.collections))
1484 1489
         self.collections.append(collection)
1485 1490
         self._set_artist_props(collection)
1486 1491
 
@@ -1512,7 +1517,9 @@ def add_line(self, line):
1512 1517
         return line
1513 1518
 
1514 1519
     def _update_line_limits(self, line):
1515  
-        """Figures out the data limit of the given line, updating self.dataLim."""
  1520
+        """
  1521
+        Figures out the data limit of the given line, updating self.dataLim.
  1522
+        """
1516 1523
         path = line.get_path()
1517 1524
         if path.vertices.size == 0:
1518 1525
             return
@@ -1596,7 +1603,6 @@ def _update_patch_limits(self, patch):
1596 1603
             self.update_datalim(xys, updatex=updatex,
1597 1604
                                      updatey=updatey)
1598 1605
 
1599  
-
1600 1606
     def add_table(self, tab):
1601 1607
         """
1602 1608
         Add a :class:`~matplotlib.tables.Table` instance to the
@@ -1619,12 +1625,11 @@ def add_container(self, container):
1619 1625
         """
1620 1626
         label = container.get_label()
1621 1627
         if not label:
1622  
-            container.set_label('_container%d'%len(self.containers))
  1628
+            container.set_label('_container%d' % len(self.containers))
1623 1629
         self.containers.append(container)
1624 1630
         container.set_remove_method(lambda h: self.containers.remove(h))
1625 1631
         return container
1626 1632
 
1627  
-
1628 1633
     def relim(self):
1629 1634
         """
1630 1635
         Recompute the data limits based on current artists.
@@ -1643,13 +1648,16 @@ def relim(self):
1643 1648
             self._update_patch_limits(p)
1644 1649
 
1645 1650
     def update_datalim(self, xys, updatex=True, updatey=True):
1646  
-        """Update the data lim bbox with seq of xy tups or equiv. 2-D array"""
  1651
+        """
  1652
+        Update the data lim bbox with seq of xy tups or equiv. 2-D array
  1653
+        """
1647 1654
         # if no data is set currently, the bbox will ignore its
1648 1655
         # limits and set the bound to be the bounds of the xydata.
1649 1656
         # Otherwise, it will compute the bounds of it's current data
1650 1657
         # and the data in xydata
1651 1658
 
1652  
-        if iterable(xys) and not len(xys): return
  1659
+        if iterable(xys) and not len(xys):
  1660
+            return
1653 1661
         if not ma.isMaskedArray(xys):
1654 1662
             xys = np.asarray(xys)
1655 1663
         self.dataLim.update_from_data_xy(xys, self.ignore_existing_data_limits,
@@ -1657,12 +1665,15 @@ def update_datalim(self, xys, updatex=True, updatey=True):
1657 1665
         self.ignore_existing_data_limits = False
1658 1666
 
1659 1667
     def update_datalim_numerix(self, x, y):
1660  
-        """Update the data lim bbox with seq of xy tups"""
  1668
+        """
  1669
+        Update the data lim bbox with seq of xy tups
  1670
+        """
1661 1671
         # if no data is set currently, the bbox will ignore it's
1662 1672
         # limits and set the bound to be the bounds of the xydata.
1663 1673
         # Otherwise, it will compute the bounds of it's current data
1664 1674
         # and the data in xydata
1665  
-        if iterable(x) and not len(x): return
  1675
+        if iterable(x) and not len(x):
  1676
+            return
1666 1677
         self.dataLim.update_from_data(x, y, self.ignore_existing_data_limits)
1667 1678
         self.ignore_existing_data_limits = False
1668 1679
 
@@ -1676,7 +1687,8 @@ def update_datalim_bounds(self, bounds):
1676 1687
     def _process_unit_info(self, xdata=None, ydata=None, kwargs=None):
1677 1688
         """Look for unit *kwargs* and update the axis instances as necessary"""
1678 1689
 
1679  
-        if self.xaxis is None or self.yaxis is None: return
  1690
+        if self.xaxis is None or self.yaxis is None:
  1691
+            return
1680 1692
 
1681 1693
         #print 'processing', self.get_geometry()
1682 1694
         if xdata is not None:
@@ -1693,10 +1705,10 @@ def _process_unit_info(self, xdata=None, ydata=None, kwargs=None):
1693 1705
 
1694 1706
         # process kwargs 2nd since these will override default units
1695 1707
         if kwargs is not None:
1696  
-            xunits = kwargs.pop( 'xunits', self.xaxis.units)
  1708
+            xunits = kwargs.pop('xunits', self.xaxis.units)
1697 1709
             if self.name == 'polar':
1698  
-                xunits = kwargs.pop( 'thetaunits', xunits )
1699  
-            if xunits!=self.xaxis.units:
  1710
+                xunits = kwargs.pop('thetaunits', xunits)
  1711
+            if xunits != self.xaxis.units:
1700 1712
                 #print '\tkw setting xunits', xunits
1701 1713
                 self.xaxis.set_units(xunits)
1702 1714
                 # If the units being set imply a different converter,
@@ -1706,8 +1718,8 @@ def _process_unit_info(self, xdata=None, ydata=None, kwargs=None):
1706 1718
 
1707 1719
             yunits = kwargs.pop('yunits', self.yaxis.units)
1708 1720
             if self.name == 'polar':
1709  
-                yunits = kwargs.pop( 'runits', yunits )
1710  
-            if yunits!=self.yaxis.units:
  1721
+                yunits = kwargs.pop('runits', yunits)
  1722
+            if yunits != self.yaxis.units:
1711 1723
                 #print '\tkw setting yunits', yunits
1712 1724
                 self.yaxis.set_units(yunits)
1713 1725
                 # If the units being set imply a different converter,
@@ -1791,7 +1803,6 @@ def set_ymargin(self, m):
1791 1803
             raise ValueError("margin must be in range 0 to 1")
1792 1804
         self._ymargin = m
1793 1805
 
1794  
-
1795 1806
     def margins(self, *args, **kw):
1796 1807
         """
1797 1808
         Set or retrieve autoscaling margins.
@@ -1849,7 +1860,6 @@ def margins(self, *args, **kw):
1849 1860
 
1850 1861
         self.autoscale_view(tight=tight, scalex=scalex, scaley=scaley)
1851 1862
 
1852  
-
1853 1863
     def set_rasterization_zorder(self, z):
1854 1864
         """
1855 1865
         Set zorder value below which artists will be rasterized.  Set
@@ -1905,7 +1915,6 @@ def autoscale(self, enable=True, axis='both', tight=None):
1905 1915
                 scaley = self._autoscaleYon
1906 1916
         self.autoscale_view(tight=tight, scalex=scalex, scaley=scaley)
1907 1917
 
1908  
-
1909 1918
     def autoscale_view(self, tight=None, scalex=True, scaley=True):
1910 1919
         """
1911 1920
         Autoscale the view limits using the data limits. You can
@@ -1913,17 +1922,16 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
1913 1922
         setting *scaley* to *False*.  The autoscaling preserves any
1914 1923
         axis direction reversal that has already been done.
1915 1924
 
1916  
-        The data limits are not updated automatically when artist
1917  
-        data are changed after the artist has been added to an
1918  
-        Axes instance.  In that case, use
1919  
-        :meth:`matplotlib.axes.Axes.relim`
1920  
-        prior to calling autoscale_view.
  1925
+        The data limits are not updated automatically when artist data are
  1926
+        changed after the artist has been added to an Axes instance.  In that
  1927
+        case, use :meth:`matplotlib.axes.Axes.relim` prior to calling
  1928
+        autoscale_view.
1921 1929
         """
1922 1930
         if tight is None:
1923 1931
             # if image data only just use the datalim
1924  
-            _tight = self._tight or (len(self.images)>0 and
1925  
-                                     len(self.lines)==0 and
1926  
-                                     len(self.patches)==0)
  1932
+            _tight = self._tight or (len(self.images) > 0 and
  1933
+                                     len(self.lines) == 0 and
  1934
+                                     len(self.patches) == 0)
1927 1935
         else:
1928 1936
             _tight = self._tight = bool(tight)
1929 1937
 
@@ -1977,7 +1985,8 @@ def draw(self, renderer=None, inframe=False):
1977 1985
 
1978 1986
         if renderer is None:
1979 1987
             raise RuntimeError('No renderer defined')
1980  
-        if not self.get_visible(): return
  1988
+        if not self.get_visible():
  1989
+            return
1981 1990
         renderer.open_group('axes')
1982 1991
 
1983 1992
         locator = self.get_axes_locator()
@@ -1987,7 +1996,6 @@ def draw(self, renderer=None, inframe=False):
1987 1996
         else:
1988 1997
             self.apply_aspect()
1989 1998
 
1990  
-
1991 1999
         artists = []
1992 2000
 
1993 2001
         artists.extend(self.collections)
@@ -2003,7 +2011,8 @@ def draw(self, renderer=None, inframe=False):
2003 2011
                 self.xaxis.set_zorder(2.5)
2004 2012
                 self.yaxis.set_zorder(2.5)
2005 2013
             artists.extend([self.xaxis, self.yaxis])
2006  
-        if not inframe: artists.append(self.title)
  2014
+        if not inframe:
  2015
+            artists.append(self.title)
2007 2016
         artists.extend(self.tables)
2008 2017
         if self.legend_ is not None:
2009 2018
             artists.append(self.legend_)
@@ -2014,18 +2023,17 @@ def draw(self, renderer=None, inframe=False):
2014 2023
         if self.axison and self._frameon:
2015 2024
             artists.extend(self.spines.itervalues())
2016 2025
 
2017  
-        dsu = [ (a.zorder, a) for a in artists
2018  
-                if not a.get_animated() ]
  2026
+        dsu = [(a.zorder, a) for a in artists
  2027
+               if not a.get_animated()]
2019 2028
 
2020 2029
         # add images to dsu if the backend support compositing.
2021 2030
         # otherwise, does the manaul compositing  without adding images to dsu.
2022  
-        if len(self.images)<=1 or renderer.option_image_nocomposite():
  2031
+        if len(self.images) <= 1 or renderer.option_image_nocomposite():
2023 2032
             dsu.extend([(im.zorder, im) for im in self.images])
2024 2033
             _do_composite = False
2025 2034
         else:
2026 2035
             _do_composite = True
2027 2036
 
2028  
-
2029 2037
         dsu.sort(key=itemgetter(0))
2030 2038
 
2031 2039
         # rasterize artists with negative zorder
@@ -2048,17 +2056,16 @@ def draw(self, renderer=None, inframe=False):
2048 2056
             # make a composite image blending alpha
2049 2057
             # list of (mimage.Image, ox, oy)
2050 2058
 
2051  
-            zorder_images = [(im.zorder, im) for im in self.images \
  2059
+            zorder_images = [(im.zorder, im) for im in self.images
2052 2060
                              if im.get_visible()]
2053 2061
             zorder_images.sort(key=lambda x: x[0])
2054 2062
 
2055 2063
             mag = renderer.get_image_magnification()
2056  
-            ims = [(im.make_image(mag),0,0) for z,im in zorder_images]
2057  
-
  2064
+            ims = [(im.make_image(mag), 0, 0) for z, im in zorder_images]
2058 2065
 
2059 2066
             l, b, r, t = self.bbox.extents
2060  
-            width = mag*((round(r) + 0.5) - (round(l) - 0.5))
2061  
-            height = mag*((round(t) + 0.5) - (round(b) - 0.5))
  2067
+            width = mag * ((round(r) + 0.5) - (round(l) - 0.5))
  2068
+            height = mag * ((round(t) + 0.5) - (round(b) - 0.5))
2062 2069
             im = mimage.from_images(height,
2063 2070
                                     width,
2064 2071
                                     ims)
@@ -2144,7 +2151,8 @@ def get_axisbelow(self):
2144 2151
 
2145 2152
     def set_axisbelow(self, b):
2146 2153
         """
2147  
-        Set whether the axis ticks and gridlines are above or below most artists
  2154
+        Set whether the axis ticks and gridlines are above or below most
  2155
+        artists
2148 2156
 
2149 2157
         ACCEPTS: [ *True* | *False* ]
2150 2158
         """
@@ -2186,9 +2194,9 @@ def grid(self, b=None, which='major', axis='both', **kwargs):
2186 2194
         b = _string_to_bool(b)
2187 2195
 
2188 2196
         if axis == 'x' or  axis == 'both':
2189  
-          self.xaxis.grid(b, which=which, **kwargs)
  2197
+            self.xaxis.grid(b, which=which, **kwargs)
2190 2198
         if axis == 'y' or  axis == 'both':
2191  
-          self.yaxis.grid(b, which=which, **kwargs)
  2199
+            self.yaxis.grid(b, which=which, **kwargs)
2192 2200
 
2193 2201
     def ticklabel_format(self, **kwargs):
2194 2202
         """
@@ -2237,7 +2245,7 @@ def ticklabel_format(self, **kwargs):
2237 2245
         if scilimits is not None:
2238 2246
             try:
2239 2247
                 m, n = scilimits
2240  
-                m+n+1  # check that both are numbers
  2248
+                m + n + 1  # check that both are numbers
2241 2249
             except (ValueError, TypeError):
2242 2250
                 raise ValueError("scilimits must be a sequence of 2 integers")
2243 2251
         if style[:3] == 'sci':
@@ -2448,12 +2456,14 @@ def set_xbound(self, lower=None, upper=None):
2448 2456
         It will not change the _autoscaleXon attribute.
2449 2457
         """
2450 2458
         if upper is None and iterable(lower):
2451  
-            lower,upper = lower
  2459
+            lower, upper = lower
2452 2460
 
2453  
-        old_lower,old_upper = self.get_xbound()
  2461
+        old_lower, old_upper = self.get_xbound()
2454 2462
 
2455  
-        if lower is None: lower = old_lower
2456  
-        if upper is None: upper = old_upper
  2463
+        if lower is None:
  2464
+            lower = old_lower
  2465
+        if upper is None:
  2466
+            upper = old_upper
2457 2467
 
2458 2468
         if self.xaxis_inverted():
2459 2469
             if lower < upper:
@@ -3226,6 +3236,7 @@ def dist(a):
3226 3236
 
3227 3237
         artists = self.lines + self.patches + self.texts
3228 3238
         if callable(among):
  3239
+            # FIXME test is not defined
3229 3240
             artists = filter(test, artists)
3230 3241
         elif iterable(among):
3231 3242
             amongd = dict([(k,1) for k in among])
@@ -3690,7 +3701,6 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
3690 3701
         self.autoscale_view(scaley=False)
3691 3702
         return p
3692 3703
 
3693  
-
3694 3704
     @docstring.dedent
3695 3705
     def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
3696 3706
                      label='', **kwargs):
@@ -4071,7 +4081,6 @@ def plot_date(self, x, y, fmt='bo', tz=None, xdate=True, ydate=False,
4071 4081
 
4072 4082
         return ret
4073 4083
 
4074  
-
4075 4084
     @docstring.dedent_interpd
4076 4085
     def loglog(self, *args, **kwargs):
4077 4086
         """
@@ -4385,7 +4394,6 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
4385 4394
             b = None
4386 4395
         return lags, c, a, b
4387 4396
 
4388  
-
4389 4397
     def _get_legend_handles(self, legend_handler_map=None):
4390 4398
         "return artists that wil