From: <ds...@us...> - 2007-07-17 13:40:57
|
Revision: 3551 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3551&view=rev Author: dsdale Date: 2007-07-17 06:40:56 -0700 (Tue, 17 Jul 2007) Log Message: ----------- ticker.py import numpy rather than numerix Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/ticker.py Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2007-07-17 12:55:05 UTC (rev 3550) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2007-07-17 13:40:56 UTC (rev 3551) @@ -113,8 +113,7 @@ import sys, os, re, time, math, warnings from mlab import linspace from matplotlib import verbose, rcParams -from numerix import absolute, arange, array, asarray, Float, floor, log, \ - logical_and, nonzero, ones, take, zeros +from numpy import absolute, arange, array, asarray, floor, log, logical_and, nonzero, ones, take, zeros from matplotlib.numerix.mlab import amin, amax, std, mean from matplotlib.mlab import frange from cbook import strip_math This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2007-07-18 07:38:11
|
Revision: 3556 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3556&view=rev Author: efiring Date: 2007-07-18 00:38:05 -0700 (Wed, 18 Jul 2007) Log Message: ----------- Standardized imports in ticker.py Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/ticker.py Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2007-07-17 22:33:42 UTC (rev 3555) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2007-07-18 07:38:05 UTC (rev 3556) @@ -111,14 +111,17 @@ from __future__ import division import sys, os, re, time, math, warnings -from mlab import linspace +import numpy as npy +import matplotlib as mpl from matplotlib import verbose, rcParams -from numpy import absolute, arange, array, asarray, floor, log, logical_and, nonzero, ones, take, zeros -from matplotlib.numerix.mlab import amin, amax, std, mean -from matplotlib.mlab import frange -from cbook import strip_math -from transforms import nonsingular, Value, Interval +from matplotlib import cbook +from matplotlib import mlab +from matplotlib import transforms as mtrans + + + + class TickHelper: viewInterval = None @@ -147,8 +150,8 @@ cases where the Intervals do not need to be updated automatically. ''' - self.dataInterval = Interval(Value(vmin), Value(vmax)) - self.viewInterval = Interval(Value(vmin), Value(vmax)) + self.dataInterval = mtrans.Interval(mtrans.Value(vmin), mtrans.Value(vmax)) + self.viewInterval = mtrans.Interval(mtrans.Value(vmin), mtrans.Value(vmax)) class Formatter(TickHelper): """ @@ -330,7 +333,7 @@ sciNotStr = r'{\times}'+self.format_data(10**self.orderOfMagnitude) else: sciNotStr = u'\xd7'+'1e%d'% self.orderOfMagnitude - if self._useMathText or self._usetex: + if self._useMathText or self._usetex: return ''.join(('$',sciNotStr,offsetStr,'$')) else: return ''.join((sciNotStr,offsetStr)) else: return '' @@ -352,16 +355,16 @@ if locs is None or not len(locs) or range == 0: self.offset = 0 return - ave_loc = mean(locs) + ave_loc = npy.mean(locs) if ave_loc: # dont want to take log10(0) - ave_oom = math.floor(math.log10(mean(absolute(locs)))) + ave_oom = math.floor(math.log10(npy.mean(npy.absolute(locs)))) range_oom = math.floor(math.log10(range)) - if absolute(ave_oom-range_oom) >= 3: # four sig-figs + if npy.absolute(ave_oom-range_oom) >= 3: # four sig-figs if ave_loc < 0: - self.offset = math.ceil(amax(locs)/10**range_oom)*10**range_oom + self.offset = math.ceil(npy.max(locs)/10**range_oom)*10**range_oom else: - self.offset = math.floor(amin(locs)/10**(range_oom))*10**(range_oom) + self.offset = math.floor(npy.min(locs)/10**(range_oom))*10**(range_oom) else: self.offset = 0 def _set_orderOfMagnitude(self,range): @@ -370,7 +373,7 @@ if not self._scientific: self.orderOfMagnitude = 0 return - locs = absolute(self.locs) + locs = npy.absolute(self.locs) if self.offset: oom = math.floor(math.log10(range)) else: if locs[0] > locs[-1]: val = locs[0] @@ -388,7 +391,7 @@ # set the format string to format all the ticklabels # The floating point black magic (adding 1e-15 and formatting # to 8 digits) may warrant review and cleanup. - locs = (array(self.locs)-self.offset) / 10**self.orderOfMagnitude+1e-15 + locs = (npy.asarray(self.locs)-self.offset) / 10**self.orderOfMagnitude+1e-15 sigfigs = [len(str('%1.8f'% loc).split('.')[1].rstrip('0')) \ for loc in locs] sigfigs.sort() @@ -397,7 +400,7 @@ def pprint_val(self, x): xp = (x-self.offset)/10**self.orderOfMagnitude - if absolute(xp) < 1e-8: xp = 0 + if npy.absolute(xp) < 1e-8: xp = 0 return self.format % xp def _formatSciNotation(self, s): @@ -464,7 +467,7 @@ def format_data(self,value): self.labelOnlyBase = False - value = strip_math(self.__call__(value)) + value = cbook.strip_math(self.__call__(value)) self.labelOnlyBase = True return value @@ -570,7 +573,7 @@ def autoscale(self): 'autoscale the view limits' self.verify_intervals() - return nonsingular(*self.dataInterval.get_bounds()) + return mtrans.nonsingular(*self.dataInterval.get_bounds()) def pan(self, numsteps): 'Pan numticks (can be positive or negative)' @@ -611,7 +614,7 @@ def __call__(self): 'Return the locations of the ticks' dmin, dmax = self.dataInterval.get_bounds() - return arange(dmin + self.offset, dmax+1, self._base) + return npy.arange(dmin + self.offset, dmax+1, self._base) class FixedLocator(Locator): @@ -684,7 +687,7 @@ if self.numticks==0: return [] - ticklocs = linspace(vmin, vmax, self.numticks) + ticklocs = npy.linspace(vmin, vmax, self.numticks) return ticklocs @@ -712,7 +715,7 @@ vmin = math.floor(scale*vmin)/scale vmax = math.ceil(scale*vmax)/scale - return nonsingular(vmin, vmax) + return mtrans.nonsingular(vmin, vmax) def closeto(x,y): @@ -776,9 +779,8 @@ if vmax<vmin: vmin, vmax = vmax, vmin vmin = self._base.ge(vmin) - - locs = frange(vmin, vmax+0.001*self._base.get_base(), self._base.get_base()) - + base = self._base.get_base() + locs = mlab.frange(vmin, vmax+0.001*base, base) return locs def autoscale(self): @@ -796,7 +798,7 @@ vmin -=1 vmax +=1 - return nonsingular(vmin, vmax) + return mtrans.nonsingular(vmin, vmax) def scale_range(vmin, vmax, n = 1, threshold=100): dv = abs(vmax - vmin) @@ -858,20 +860,20 @@ if self._trim: extra_bins = int(divmod((best_vmax - vmax), step)[0]) nbins -= extra_bins - return (arange(nbins+1) * step + best_vmin + offset) + return (npy.arange(nbins+1) * step + best_vmin + offset) def __call__(self): self.verify_intervals() vmin, vmax = self.viewInterval.get_bounds() - vmin, vmax = nonsingular(vmin, vmax, expander = 0.05) + vmin, vmax = mtrans.nonsingular(vmin, vmax, expander = 0.05) return self.bin_boundaries(vmin, vmax) def autoscale(self): self.verify_intervals() dmin, dmax = self.dataInterval.get_bounds() - dmin, dmax = nonsingular(dmin, dmax, expander = 0.05) - return take(self.bin_boundaries(dmin, dmax), [0,-1]) + dmin, dmax = mtrans.nonsingular(dmin, dmax, expander = 0.05) + return npy.take(self.bin_boundaries(dmin, dmax), [0,-1]) def decade_down(x, base=10): @@ -915,7 +917,7 @@ if subs is None: self._subs = None # autosub else: - self._subs = array(subs)+0.0 + self._subs = npy.asarray(subs)+0.0 def _set_numticks(self): self.numticks = 15 # todo; be smart here; this is just for dev @@ -936,9 +938,9 @@ numdec = math.floor(vmax)-math.ceil(vmin) if self._subs is None: # autosub - if numdec>10: subs = array([1.0]) - elif numdec>6: subs = arange(2.0, b, 2.0) - else: subs = arange(2.0, b) + if numdec>10: subs = npy.array([1.0]) + elif numdec>6: subs = npy.arange(2.0, b, 2.0) + else: subs = npy.arange(2.0, b) else: subs = self._subs @@ -946,10 +948,11 @@ while numdec/stride+1 > self.numticks: stride += 1 - for decadeStart in b**arange(math.floor(vmin),math.ceil(vmax)+stride, stride): + for decadeStart in b**npy.arange(math.floor(vmin), + math.ceil(vmax)+stride, stride): ticklocs.extend( subs*decadeStart ) - return array(ticklocs) + return npy.array(ticklocs) def autoscale(self): 'Try to choose the view limits intelligently' @@ -970,7 +973,7 @@ if vmin==vmax: vmin = decade_down(vmin,self._base) vmax = decade_up(vmax,self._base) - return nonsingular(vmin, vmax) + return mtrans.nonsingular(vmin, vmax) class AutoLocator(MaxNLocator): def __init__(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2008-01-28 15:45:23
|
Revision: 4903 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4903&view=rev Author: dsdale Date: 2008-01-28 07:43:55 -0800 (Mon, 28 Jan 2008) Log Message: ----------- don't use unicode strings with usetex Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/ticker.py Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2008-01-28 13:28:20 UTC (rev 4902) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2008-01-28 15:43:55 UTC (rev 4903) @@ -336,7 +336,7 @@ return ''.join(('$',sciNotStr,r'\mathdefault{',offsetStr,'}$')) elif self._usetex: if sciNotStr != '': - sciNotStr = u'\xd7%s' % sciNotStr + sciNotStr = r'\times%s' % sciNotStr return ''.join(('$',sciNotStr,offsetStr,'$')) else: return ''.join((sciNotStr,offsetStr)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-28 16:46:57
|
Revision: 5289 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5289&view=rev Author: jdh2358 Date: 2008-05-28 09:46:53 -0700 (Wed, 28 May 2008) Log Message: ----------- reverting due to PDF problem Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/ticker.py Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2008-05-28 16:44:32 UTC (rev 5288) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2008-05-28 16:46:53 UTC (rev 5289) @@ -429,7 +429,7 @@ else: return r'%s%s'%(significand, exponent) else: - sign = sign.replace('-', u'\u2212') # crashes PDF + #sign = sign.replace('-', u'\u2212') # crashes PDF return ('%se%s%s' %(significand, sign, exponent)).rstrip('e') except IndexError, msg: return s This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-28 16:51:41
|
Revision: 5290 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5290&view=rev Author: jdh2358 Date: 2008-05-28 09:51:39 -0700 (Wed, 28 May 2008) Log Message: ----------- reverting due to PDF problem Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/ticker.py Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2008-05-28 16:46:53 UTC (rev 5289) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2008-05-28 16:51:39 UTC (rev 5290) @@ -423,7 +423,7 @@ # reformat 1x10^y as 10^y significand = '' if exponent: - exponent = u'10^{%s%s}'%(sign, exponent) + exponent = '10^{%s%s}'%(sign, exponent) if significand and exponent: return r'%s{\times}%s'%(significand, exponent) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-29 15:55:57
|
Revision: 5302 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5302&view=rev Author: jdh2358 Date: 2008-05-29 08:55:55 -0700 (Thu, 29 May 2008) Log Message: ----------- turned off unicode minus for usetex Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/ticker.py Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2008-05-29 15:13:52 UTC (rev 5301) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2008-05-29 15:55:55 UTC (rev 5302) @@ -179,7 +179,7 @@ """ some classes may want to replace a hyphen for minus with the proper unicode symbol as described here - + http://sourceforge.net/tracker/index.php?func=detail&aid=1962574&group_id=80706&atid=560720. The default is to do nothing @@ -191,7 +191,7 @@ should have an explicit format_data_short method """ return s - + class NullFormatter(Formatter): 'Always return the empty string' def __call__(self, x, pos=None): @@ -303,7 +303,8 @@ def fix_minus(self, s): 'use a unicode minus rather than hyphen' - return s.replace('-', u'\u2212') + if rcParams['text.usetex']: return s + else: return s.replace('-', u'\u2212') def __call__(self, x, pos=None): 'Return the format for tick val x at position pos' @@ -366,7 +367,7 @@ s = ''.join(('$',sciNotStr,offsetStr,'$')) else: s = ''.join((sciNotStr,offsetStr)) - + return self.fix_minus(s) def set_locs(self, locs): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |