|
From: <jd...@us...> - 2010-02-17 15:25:46
|
Revision: 8140
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8140&view=rev
Author: jdh2358
Date: 2010-02-17 15:25:38 +0000 (Wed, 17 Feb 2010)
Log Message:
-----------
added customizable keymap patch; L or k works for log scaling xaxis
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/doc/users/navigation_toolbar.rst
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/rcsetup.py
trunk/matplotlib/matplotlibrc.template
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/mathtex:1-7263 /branches/v0_99_maint:1-8135
+ <<<<<<< (modified)
/branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /trunk/matplotlib:1-7315=======
/branches/mathtex:1-7263 /branches/v0_99_maint:1-8135>>>>>>> (latest)
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2010-02-17 02:43:26 UTC (rev 8139)
+++ trunk/matplotlib/CHANGELOG 2010-02-17 15:25:38 UTC (rev 8140)
@@ -1,3 +1,8 @@
+2010-02-17 Added Gokhan's and Mattias' customizable keybindings patch
+ for the toolbar. You can now set the keymap.* properties
+ in the matplotlibrc file. Newbindings were added for
+ toggling log scaling on the x-axis. JDH
+
2010-02-16 Committed TJ's filled marker patch for
left|right|bottom|top|full filled markers. See
examples/pylab_examples/filledmarker_demo.py. JDH
Modified: trunk/matplotlib/doc/users/navigation_toolbar.rst
===================================================================
--- trunk/matplotlib/doc/users/navigation_toolbar.rst 2010-02-17 02:43:26 UTC (rev 8139)
+++ trunk/matplotlib/doc/users/navigation_toolbar.rst 2010-02-17 15:25:38 UTC (rev 8140)
@@ -79,6 +79,8 @@
Navigation Keyboard Shortcuts
-----------------------------
+The following table holds all the default keys, which can be overwritten by use of your matplotlibrc (#keymap.\*).
+
================================== ==============================================
Command Keyboard Shortcut(s)
================================== ==============================================
@@ -93,6 +95,7 @@
Constrain pan/zoom to y axis hold **y**
Preserve aspect ratio hold **CONTROL**
Toggle grid **g**
+Toggle x axis scale (log/linear) **L** or **k**
Toggle y axis scale (log/linear) **l**
================================== ==============================================
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2010-02-17 02:43:26 UTC (rev 8139)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2010-02-17 15:25:38 UTC (rev 8140)
@@ -1888,50 +1888,85 @@
# self.destroy() # how cruel to have to destroy oneself!
# return
- if event.key == 'f':
+ # Load key-mappings from your matplotlibrc file.
+ fullscreen_keys = rcParams['keymap.fullscreen']
+ home_keys = rcParams['keymap.home']
+ back_keys = rcParams['keymap.back']
+ forward_keys = rcParams['keymap.forward']
+ pan_keys = rcParams['keymap.pan']
+ zoom_keys = rcParams['keymap.zoom']
+ save_keys = rcParams['keymap.save']
+ grid_keys = rcParams['keymap.grid']
+ toggle_yscale_keys = rcParams['keymap.yscale']
+ toggle_xscale_keys = rcParams['keymap.xscale']
+ all = rcParams['keymap.all_axes']
+
+ # toggle fullscreen mode (default key 'f')
+ if event.key in fullscreen_keys:
self.full_screen_toggle()
- # *h*ome or *r*eset mnemonic
- elif event.key == 'h' or event.key == 'r' or event.key == "home":
+ # home or reset mnemonic (default key 'h', 'home' and 'r')
+ elif event.key in home_keys:
self.canvas.toolbar.home()
- # c and v to enable left handed quick navigation
- elif event.key == 'left' or event.key == 'c' or event.key == 'backspace':
+ # forward / backward keys to enable left handed quick navigation
+ # (default key for backward: 'left', 'backspace' and 'c')
+ elif event.key in back_keys:
self.canvas.toolbar.back()
- elif event.key == 'right' or event.key == 'v':
+ # (default key for forward: 'right' and 'v')
+ elif event.key in forward_keys:
self.canvas.toolbar.forward()
- # *p*an mnemonic
- elif event.key == 'p':
+ # pan mnemonic (default key 'p')
+ elif event.key in pan_keys:
self.canvas.toolbar.pan()
- # z*o*om mnemonic
- elif event.key == 'o':
+ # zoom mnemonic (default key 'o')
+ elif event.key in zoom_keys:
self.canvas.toolbar.zoom()
- elif event.key == 's':
+ # saving current figure (default key 's')
+ elif event.key in save_keys:
self.canvas.toolbar.save_figure(self.canvas.toolbar)
if event.inaxes is None:
return
# the mouse has to be over an axes to trigger these
- if event.key == 'g':
+ # switching on/off a grid in current axes (default key 'g')
+ if event.key in grid_keys:
event.inaxes.grid()
self.canvas.draw()
- elif event.key == 'l':
+ # toggle scaling of y-axes between 'log and 'linear' (default key 'l')
+ elif event.key in toggle_yscale_keys:
ax = event.inaxes
scale = ax.get_yscale()
- if scale=='log':
+ if scale == 'log':
ax.set_yscale('linear')
ax.figure.canvas.draw()
- elif scale=='linear':
+ elif scale == 'linear':
ax.set_yscale('log')
ax.figure.canvas.draw()
+ # toggle scaling of x-axes between 'log and 'linear' (default key 'k')
+ elif event.key in toggle_xscale_keys:
+ ax = event.inaxes
+ scalex = ax.get_xscale()
+ if scalex == 'log':
+ ax.set_xscale('linear')
+ ax.figure.canvas.draw()
+ elif scalex == 'linear':
+ ax.set_xscale('log')
+ ax.figure.canvas.draw()
- elif event.key is not None and (event.key.isdigit() and event.key!='0') or event.key=='a':
- # 'a' enables all axes
- if event.key!='a':
- n=int(event.key)-1
+ elif event.key is not None and \
+ (event.key.isdigit() and event.key!='0') or event.key in all:
+ # keys in list 'all' enables all axes (default key 'a'),
+ # otherwise if key is a number only enable this particular axes
+ # if it was the axes, where the event was raised
+ if not (event.key in all):
+ n = int(event.key)-1
for i, a in enumerate(self.canvas.figure.get_axes()):
- if event.x is not None and event.y is not None and a.in_axes(event):
- if event.key=='a':
+ # consider axes, in which the event was raised
+ # FIXME: Why only this axes?
+ if event.x is not None and event.y is not None \
+ and a.in_axes(event):
+ if event.key in all:
a.set_navigate(True)
else:
a.set_navigate(i==n)
Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/rcsetup.py 2010-02-17 02:43:26 UTC (rev 8139)
+++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2010-02-17 15:25:38 UTC (rev 8140)
@@ -546,9 +546,22 @@
'path.simplify' : [True, validate_bool],
'path.simplify_threshold' : [1.0 / 9.0, ValidateInterval(0.0, 1.0)],
- 'agg.path.chunksize' : [0, validate_int] # 0 to disable chunking;
- # recommend about 20000 to
- # enable. Experimental.
+ 'agg.path.chunksize' : [0, validate_int], # 0 to disable chunking;
+ # recommend about 20000 to
+ # enable. Experimental.
+ # key-mappings
+ 'keymap.fullscreen' : ['f', validate_stringlist],
+ 'keymap.home' : [['h', 'r', 'home'], validate_stringlist],
+ 'keymap.back' : [['left', 'c', 'backspace'], validate_stringlist],
+ 'keymap.forward' : [['right', 'v'], validate_stringlist],
+ 'keymap.pan' : ['p', validate_stringlist],
+ 'keymap.zoom' : ['o', validate_stringlist],
+ 'keymap.save' : ['s', validate_stringlist],
+ 'keymap.grid' : ['g', validate_stringlist],
+ 'keymap.yscale' : ['l', validate_stringlist],
+ 'keymap.xscale' : [['k', 'L'], validate_stringlist],
+ 'keymap.all_axes' : ['a', validate_stringlist]
+
}
if __name__ == '__main__':
Modified: trunk/matplotlib/matplotlibrc.template
===================================================================
--- trunk/matplotlib/matplotlibrc.template 2010-02-17 02:43:26 UTC (rev 8139)
+++ trunk/matplotlib/matplotlibrc.template 2010-02-17 15:25:38 UTC (rev 8140)
@@ -360,3 +360,20 @@
# from matplotlib import verbose.
#verbose.level : silent # one of silent, helpful, debug, debug-annoying
#verbose.fileo : sys.stdout # a log filename, sys.stdout or sys.stderr
+
+# Event keys to interact with figures/plots via keyboard.
+# Customize these settings according to your needs.
+# Leave the field(s) empty if you don't need a key-map. (i.e., fullscreen : '')
+
+#keymap.fullscreen : f # toggling
+#keymap.home : h, r, home # home or reset mnemonic
+#keymap.back : left, c, backspace # forward / backward keys to enable
+#keymap.forward : right, v # left handed quick navigation
+#keymap.pan : p # pan mnemonic
+#keymap.zoom : o # zoom mnemonic
+#keymap.save : s # saving current figure
+#keymap.grid : g # switching on/off a grid in current axes
+#keymap.yscale : l # toggle scaling of y-axes ('log'/'linear')
+#keymap.xscale : L, k # toggle scaling of x-axes ('log'/'linear')
+#keymap.all_axes : a # enable all axes
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|