From: <jd...@us...> - 2008-06-03 13:37:37
|
Revision: 5372 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5372&view=rev Author: jdh2358 Date: 2008-06-03 06:36:33 -0700 (Tue, 03 Jun 2008) Log Message: ----------- some ports of the old locators and formatters to the new api Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/ticker.py trunk/matplotlib/matplotlibrc.template Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2008-06-03 03:16:55 UTC (rev 5371) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2008-06-03 13:36:33 UTC (rev 5372) @@ -244,9 +244,7 @@ class OldScalarFormatter(Formatter): """ - Tick location is a plain old number. If viewInterval is set, the - formatter will use %d, %1.#f or %1.ef as appropriate. If it is - not set, the formatter will do str conversion + Tick location is a plain old number. """ def __call__(self, x, pos=None): @@ -557,8 +555,11 @@ def __call__(self, x, pos=None): 'Return the format for tick val x at position pos' - self.verify_intervals() - d = abs(self.viewInterval.span()) + + + vmin, vmax = self.axis.get_view_interval() + vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = 0.05) + d = abs(vmax-vmin) b=self._base if x == 0: return '0' @@ -641,17 +642,28 @@ if numticks>2: step = numsteps*abs(ticks[0]-ticks[1]) else: - step = numsteps*self.viewInterval.span()/6 + vmin, vmax = self.axis.get_view_interval() + vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = 0.05) + d = abs(vmax-vmin) + step = numsteps*d/6. - self.viewInterval.shift(step) + vmin += step + vmax += step + self.axis.set_view_interval(vmin, vmax) + def zoom(self, direction): "Zoom in/out on axis; if direction is >0 zoom in, else zoom out" - vmin, vmax = self.viewInterval.get_bounds() + + vmin, vmax = self.axis.get_view_interval() + vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = 0.05) + interval = abs(vmax-vmin) interval = self.viewInterval.span() step = 0.1*interval*direction - self.viewInterval.set_bounds(vmin + step, vmax - step) + + self.axis.set_view_interval(vmin + step, vmax - step) + def refresh(self): 'refresh internal information based on current lim' pass @@ -731,8 +743,8 @@ def __call__(self): 'Return the locations of the ticks' - self.verify_intervals() - vmin, vmax = self.viewInterval.get_bounds() + vmin, vmax = self.axis.get_view_interval() + vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = 0.05) if vmax<vmin: vmin, vmax = vmax, vmin @@ -755,9 +767,9 @@ def autoscale(self): 'Try to choose the view limits intelligently' - self.verify_intervals() - vmin, vmax = self.dataInterval.get_bounds() + vmin, vmax = self.axis.get_data_interval() + if vmax<vmin: vmin, vmax = vmax, vmin @@ -822,7 +834,7 @@ class MultipleLocator(Locator): """ Set a tick on every integer that is multiple of base in the - viewInterval + view interval """ def __init__(self, base=1.0): @@ -1141,14 +1153,16 @@ def refresh(self): 'refresh internal information based on current lim' - d = self.viewInterval.span() + vmin, vmax = self.axis.get_view_interval() + vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = 0.05) + d = abs(vmax-vmin) self._locator = self.get_locator(d) def autoscale(self): 'Try to choose the view limits intelligently' - self.verify_intervals() - d = abs(self.dataInterval.span()) + vmin, vmax = self.axis.get_data_interval() + d = abs(vmax-vmin) self._locator = self.get_locator(d) return self._locator.autoscale() @@ -1161,7 +1175,7 @@ try: ld = math.log10(d) except OverflowError: - raise RuntimeError('AutoLocator illegal dataInterval range') + raise RuntimeError('AutoLocator illegal data interval range') fld = math.floor(ld) @@ -1173,13 +1187,9 @@ if d >= 5*base : ticksize = base elif d >= 2*base : ticksize = base/2.0 else : ticksize = base/5.0 - #print 'base, ticksize, d', base, ticksize, d, self.viewInterval - - #print self.dataInterval, d, ticksize locator = MultipleLocator(ticksize) - locator.set_view_interval(self.viewInterval) - locator.set_data_interval(self.dataInterval) + return locator Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2008-06-03 03:16:55 UTC (rev 5371) +++ trunk/matplotlib/matplotlibrc.template 2008-06-03 13:36:33 UTC (rev 5372) @@ -1,27 +1,22 @@ ### MATPLOTLIBRC FORMAT -# This is a sample matplotlib configuration file. It should be placed -# in HOME/.matplotlib/matplotlibrc (unix/linux like systems) and -# C:\Documents and Settings\yourname\.matplotlib (win32 systems) +# This is a sample matplotlib configuration file - you can find a copy +# of it on your system in +# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it +# there, please note that it will be overridden in your next install. +# If you want to keep a permanent local bopy that will not be +# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux +# like systems) and C:\Documents and Settings\yourname\.matplotlib +# (win32 systems). # -# By default, the installer will overwrite the existing file in the -# install path, so if you want to preserve your's, please move it to -# your HOME dir and set the environment variable if necessary. -# # This file is best viewed in a editor which supports python mode -# syntax highlighting -# -# Blank lines, or lines starting with a comment symbol, are ignored, -# as are trailing comments. Other lines must have the format -# -# key : val # optional comment -# -# Colors: for the color values below, you can either use -# - a matplotlib color string, such as r, k, or b -# - an rgb tuple, such as (1.0, 0.5, 0.0) -# - a hex string, such as ff00ff or #ff00ff -# - a scalar grayscale intensity such as 0.75 -# - a legal html color name, eg red, blue, darkslategray +# syntax highlighting # Blank lines, or lines starting with a comment +# symbol, are ignored, as are trailing comments. Other lines must +# have the format # key : val # optional comment # Colors: for the +# color values below, you can either use - a matplotlib color string, +# such as r, k, or b - an rgb tuple, such as (1.0, 0.5, 0.0) - a hex +# string, such as ff00ff or #ff00ff - a scalar grayscale intensity +# such as 0.75 - a legal html color name, eg red, blue, darkslategray #### CONFIGURATION BEGINS HERE # the default backend; one of GTK GTKAgg GTKCairo FltkAgg QtAgg TkAgg This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |