8000 adding zaxis and some pep8 · matplotlib/matplotlib@a53419a · GitHub
[go: up one dir, main page]

Skip to content

Commit a53419a

Browse files
committed
adding zaxis and some pep8
1 parent 9266447 commit a53419a

File tree

2 files changed

+77
-28
lines changed

2 files changed

+77
-28
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,6 +3236,7 @@ class NavigationBase(object):
32363236
locked
32373237
messagelock : `LockDraw` to know if the message is available to write
32383238
"""
3239+
32393240
_default_cursor = cursors.POINTER
32403241
_default_tools = [tools.ToolToggleGrid,
32413242
tools.ToolToggleFullScreen,
@@ -3255,6 +3256,7 @@ class NavigationBase(object):
32553256

32563257
def __init__(self, canvas, toolbar=None):
32573258
""".. automethod:: _toolbar_callback"""
3259+
32583260
self.canvas = canvas
32593261
self.toolbar = self._get_toolbar(toolbar, canvas)
32603262

@@ -3273,9 +3275,9 @@ def __init__(self, canvas, toolbar=None):
32733275
self._instances = {}
32743276
self._toggled = None
32753277

3276-
#to process keypress event
3278+
# to process keypress event
32773279
self.keypresslock = widgets.LockDraw()
3278-
#to write into toolbar message
3280+
# to write into toolbar message
32793281
self.messagelock = widgets.LockDraw()
32803282

32813283
for tool in self._default_tools:
@@ -3290,11 +3292,13 @@ def __init__(self, canvas, toolbar=None):
32903292
@classmethod
32913293
def get_default_tools(cls):
32923294
"""Get the default tools"""
3295+
32933296
return cls._defau 10000 lt_tools
32943297

32953298
@classmethod
32963299
def set_default_tools(cls, tools):
32973300
"""Set default tools"""
3301+
32983302
cls._default_tools = tools
32993303

33003304
def _get_toolbar(self, toolbar, canvas):
@@ -3312,6 +3316,7 @@ def active_toggle(self):
33123316
33133317
**string** : Currently toggled tool, or None
33143318
"""
3319+
33153320
return self._toggled
33163321

33173322
@property
@@ -3320,6 +3325,7 @@ def instances(self):
33203325
33213326
**dictionary** : Contains the active instances that are registered
33223327
"""
3328+
33233329
return self._instances
33243330

33253331
def get_tool_keymap(self, name):
@@ -3334,6 +3340,7 @@ def get_tool_keymap(self, name):
33343340
----------
33353341
list : list of keys associated with the Tool
33363342
"""
3343+
33373344
keys = [k for k, i in six.iteritems(self._keys) if i == name]
33383345
return keys
33393346

@@ -3380,6 +3387,7 @@ def unregister(self, name):
33803387
If called, next time the `Tool` is used it will be reinstantiated
33813388
instead of using the existing instance.
33823389
"""
3390+
33833391
if self._toggled == name:
33843392
self._handle_toggle(name, from_toolbar=False)
33853393
if name in self._instances:
@@ -3393,6 +3401,7 @@ def remove_tool(self, name):
33933401
name : string
33943402
Name of the Tool
33953403
"""
3404+
33963405
self.unregister(name)
33973406
del self._tools[name]
33983407
keys = [k for k, v in six.iteritems(self._keys) if v == name]
@@ -3410,6 +3419,7 @@ def add_tool(self, tool):
34103419
tool : string or `Tool` class
34113420
Reference to find the class of the Tool to be added
34123421
"""
3422+
34133423
tool_cls = self._get_cls_to_instantiate(tool)
34143424
name = tool_cls.name
34153425

@@ -3445,7 +3455,7 @@ def add_tool(self, tool):
34453455

34463456
def _get_cls_to_instantiate(self, callback_class):
34473457
if isinstance(callback_class, six.string_types):
3448-
#FIXME: make more complete searching structure
3458+
# FIXME: make more complete searching structure
34493459
if callback_class in globals():
34503460
return globals()[callback_class]
34513461

@@ -3462,6 +3472,7 @@ def trigger_tool(self, name):
34623472
34633473
Method to programatically "click" on Tools
34643474
"""
3475+
34653476
self._trigger_tool(name, None, False)
34663477

34673478
def _trigger_tool(self, name, event, from_toolbar):
@@ -3475,8 +3486,7 @@ def _trigger_tool(self, name, event, from_toolbar):
34753486
instance = self._get_instance(name)
34763487
instance.trigger(event)
34773488
else:
3478-
#Non persistent tools, are
3479-
#instantiated and forgotten (reminds me an exgirlfriend?)
3489+
# Non persistent tools, are instantiated and forgotten
34803490
tool(self.canvas.figure, event)
34813491

34823492
def _key_press(self, event):
@@ -3491,7 +3501,7 @@ def _key_press(self, event):
34913501
def _get_instance(self, name):
34923502
if name not in self._instances:
34933503
instance = self._tools[name](self.canvas.figure)
3494-
#register instance
3504+
# register instance
34953505
self._instances[name] = instance
34963506

34973507
return self._instances[name]
@@ -3508,24 +3518,25 @@ def _toolbar_callback(self, name):
35083518
Name of the tool that was activated (click) by the user using the
35093519
toolbar
35103520
"""
3521+
35113522
self._trigger_tool(name, None, True)
35123523

35133524
def _handle_toggle(self, name, event=None, from_toolbar=False):
3514-
#toggle toolbar without callback
3525+
# toggle toolbar without callback
35153526
if not from_toolbar and self.toolbar:
35163527
self.toolbar._toggle(name, False)
35173528

35183529
instance = self._get_instance(name)
35193530
if self._toggled is None:
3520-
#first trigger of tool
3531+
# first trigger of tool
35213532
self._toggled = name
35223533
elif self._toggled == name:
3523-
#second trigger of tool
3534+
# second trigger of tool
35243535
self._toggled = None
35253536
else:
3526-
#other tool is triggered so trigger toggled tool
3537+
# other tool is triggered so trigger toggled tool
35273538
if self.toolbar:
3528-
#untoggle the previous toggled tool
3539+
# untoggle the previous toggled tool
35293540
self.toolbar._toggle(self._toggled, False)
35303541
self._get_instance(self._toggled).trigger(event)
35313542
self._toggled = name
@@ -3537,6 +3548,7 @@ def _handle_toggle(self, name, event=None, from_toolbar=False):
35373548

35383549
def list_tools(self):
35393550
"""Print the list the tools controlled by `Navigation`"""
3551+
35403552
print ('_' * 80)
35413553
print ("{0:20} {1:50} {2}".format('Name (id)', 'Tool description',
35423554
'Keymap'))
@@ -3550,6 +3562,7 @@ def list_tools(self):
35503562

35513563
def update(self):
35523564
"""Reset the axes stack"""
3565+
35533566
self.views.clear()
35543567
self.positions.clear()
35553568
# self.set_history_buttons()
@@ -3585,16 +3598,21 @@ def _mouse_move(self, event):
35853598

35863599
def draw(self):
35873600
"""Redraw the canvases, update the locators"""
3601+
35883602
for a in self.canvas.figure.get_axes():
35893603
xaxis = getattr(a, 'xaxis', None)
35903604
yaxis = getattr(a, 'yaxis', None)
3605+
zaxis = getattr(a, 'zaxis', None)
35913606
locators = []
35923607
if xaxis is not None:
35933608
locators.append(xaxis.get_major_locator())
35943609
locators.append(xaxis.get_minor_locator())
35953610
if yaxis is not None:
35963611
locators.append(yaxis.get_major_locator())
35973612
locators.append(yaxis.get_minor_locator())
3613+
if zaxis is not None:
3614+
locators.append(zaxis.get_major_locator())
3615+
locators.append(zaxis.get_minor_locator())
35983616

35993617
for loc in locators:
36003618
loc.refresh()
@@ -3608,6 +3626,7 @@ def set_cursor(self, cursor):
36083626
Set the current cursor to one of the :class:`Cursors`
36093627
enums values
36103628
"""
3629+
36113630
pass
36123631

36133632
def update_view(self):
@@ -3633,6 +3652,7 @@ def update_view(self):
36333652

36343653
def push_current(self):
36353654
"""push the current view limits and position onto the stack"""
3655+
36363656
lims = []
36373657
pos = []
36383658
for a in self.canvas.figure.get_axes():
@@ -3659,6 +3679,7 @@ def draw_rubberband(self, event, caller, x0, y0, x1, y1):
36593679
caller : instance trying to draw the rubberband
36603680
x0, y0, x1, y1 : coordinates
36613681
"""
3682+
36623683
if not self.canvas.widgetlock.available(caller):
36633684
warnings.warn("%s doesn't own the canvas widgetlock" % caller)
36643685

@@ -3673,6 +3694,7 @@ def remove_rubberband(self, event, caller):
36733694
event : `FigureCanvas` event
36743695
caller : instance trying to remove the rubberband
36753696
"""
3697+
36763698
if not self.canvas.widgetlock.available(caller):
36773699
warnings.warn("%s doesn't own the canvas widgetlock" % caller)
36783700

@@ -3684,12 +3706,14 @@ class ToolbarBase(object):
36843706
----------
36853707
manager : `FigureManager` instance that integrates this `Toolbar`
36863708
"""
3709+
36873710
def __init__(self, manager):
36883711
"""
36893712
.. automethod:: _add_toolitem
36903713
.. automethod:: _remove_toolitem
36913714
.. automethod:: _toggle
36923715
"""
3716+
36933717
self.manager = manager
36943718

36953719
def _add_toolitem(self, name, description, image_file, position,
@@ -3717,6 +3741,7 @@ def _add_toolitem(self, name, description, image_file, position,
37173741
* `False` : The button is a normal button (returns to unpressed
37183742
state after release)
37193743
"""
3744+
37203745
raise NotImplementedError
37213746

37223747
def add_separator(self, pos):
@@ -3728,10 +3753,12 @@ def add_separator(self, pos):
37283753
Position where to add the separator within the toolitems
37293754
if -1 at the end
37303755
"""
3756+
37313757
pass
37323758

37333759
def set_message(self, s):
37343760
"""Display a message on toolbar or in status bar"""
3761+
37353762
pass
37363763

37373764
def _toggle(self, name, callback=False):
@@ -3746,7 +3773,8 @@ def _toggle(self, name, callback=False):
37463773
* `False`: toggle the button without calling the callback
37473774
37483775
"""
3749-
#carefull, callback means to perform or not the callback while toggling
3776+
3777+
# carefull, callback means to perform or not the callback while toggling
37503778
raise NotImplementedError
37513779

37523780
def _remove_toolitem(self, name):
@@ -3758,6 +3786,7 @@ def _remove_toolitem(self, name):
37583786
Name of the tool to remove
37593787
37603788
"""
3789+
37613790
raise NotImplementedError
37623791

37633792
def move_toolitem(self, pos_ini, pos_fin):
@@ -3770,6 +3799,7 @@ def move_toolitem(self, pos_ini, pos_fin):
37703799
pos_fin : integer
37713800
Final position of the toolitem
37723801
"""
3802+
37733803
pass
37743804

37753805
def set_toolitem_visibility(self, name, visible):
@@ -3783,4 +3813,5 @@ def set_toolitem_visibility(self, name, visible):
37833813
* `True`: set the toolitem visible
37843814
* `False`: set the toolitem invisible
37853815
"""
3816+
37863817
pass

0 commit comments

Comments
 (0)
0