SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
2
(1)
3
(1)
4
(1)
5
6
7
(3)
8
9
(1)
10
11
(6)
12
(1)
13
(2)
14
15
(1)
16
(1)
17
18
(3)
19
(3)
20
(3)
21
(2)
22
(7)
23
(4)
24
(7)
25
(2)
26
(2)
27
(2)
28
(15)
29
(5)
30
(1)



Showing results of 74

1 2 3 > >> (Page 1 of 3)
From: <jd...@us...> - 2008年04月30日 19:53:25
Revision: 5100
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5100&view=rev
Author: jdh2358
Date: 2008年04月30日 12:53:10 -0700 (2008年4月30日)
Log Message:
-----------
refinements to the rec editors plus examples
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/lib/matplotlib/mlab.py
 trunk/matplotlib/lib/mpl_toolkits/gtktools.py
Added Paths:
-----------
 trunk/matplotlib/examples/data/demodata.csv
 trunk/matplotlib/examples/date_demo.py
 trunk/matplotlib/examples/rec_edit_gtk_custom.py
 trunk/matplotlib/examples/rec_edit_gtk_simple.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2008年04月29日 21:10:44 UTC (rev 5099)
+++ trunk/matplotlib/CHANGELOG	2008年04月30日 19:53:10 UTC (rev 5100)
@@ -1,3 +1,6 @@
+2008年04月30日 Added some record array editing widgets for gtk -- see
+ examples/rec_edit*.py - JDH
+
 2008年04月29日 Fix bug in mlab.sqrtm - MM
 
 2008年04月28日 Fix bug in SVG text with Mozilla-based viewers (the symbol
Added: trunk/matplotlib/examples/data/demodata.csv
===================================================================
--- trunk/matplotlib/examples/data/demodata.csv	 (rev 0)
+++ trunk/matplotlib/examples/data/demodata.csv	2008年04月30日 19:53:10 UTC (rev 5100)
@@ -0,0 +1,11 @@
+clientid,date,weekdays,gains,prices,up
+0,2008年04月30日,Wed,-0.52458192906686452,7791404.0091921333,False
+1,2008年05月01日,Thu,0.076191536201738269,3167180.7366340165,True
+2,2008年05月02日,Fri,-0.86850970062880861,9589766.9613829032,False
+3,2008年05月03日,Sat,-0.42701083852713395,8949415.1867596991,False
+4,2008年05月04日,Sun,0.2532553652693274,937163.44375252665,True
+5,2008年05月05日,Mon,-0.68151636911081892,949579.88022264629,False
+6,2008年05月06日,Tue,0.0071911579626532168,7268426.906552773,True
+7,2008年05月07日,Wed,0.67449747200412147,7517014.782897247,True
+8,2008年05月08日,Thu,-1.1841008656818983,1920959.5423492221,False
+9,2008年05月09日,Fri,-1.5803692595811152,8456240.6198725495,False
Added: trunk/matplotlib/examples/date_demo.py
===================================================================
--- trunk/matplotlib/examples/date_demo.py	 (rev 0)
+++ trunk/matplotlib/examples/date_demo.py	2008年04月30日 19:53:10 UTC (rev 5100)
@@ -0,0 +1,14 @@
+"""
+Simple example showing how to plot a time series with datetime objects
+"""
+import datetime
+import matplotlib.pyplot as plt
+
+today = datetime.date.today()
+dates = [today+datetime.timedelta(days=i) for i in range(10)]
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.plot(dates, range(10))
+fig.autofmt_xdate()
+plt.show()
Added: trunk/matplotlib/examples/rec_edit_gtk_custom.py
===================================================================
--- trunk/matplotlib/examples/rec_edit_gtk_custom.py	 (rev 0)
+++ trunk/matplotlib/examples/rec_edit_gtk_custom.py	2008年04月30日 19:53:10 UTC (rev 5100)
@@ -0,0 +1,37 @@
+"""
+generate an editable gtk treeview widget for record arrays with custom
+formatting of the cells and show how to limit string entries to a list
+of strings
+"""
+import gtk
+import numpy as np
+import matplotlib.mlab as mlab
+import mpl_toolkits.gtktools as gtktools
+
+r = mlab.csv2rec('data/demodata.csv', converterd={'weekdays':str})
+
+
+formatd = mlab.get_formatd(r)
+formatd['date'] = mlab.FormatDate('%Y-%m-%d')
+formatd['prices'] = mlab.FormatMillions(precision=1)
+formatd['gain'] = mlab.FormatPercent(precision=2)
+
+# use a drop down combo for weekdays
+stringd = dict(weekdays=['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'])
+constant = ['clientid'] # block editing of this field
+
+
+liststore = gtktools.RecListStore(r, formatd=formatd, stringd=stringd)
+treeview = gtktools.RecTreeView(liststore, constant=constant)
+
+def mycallback(liststore, rownum, colname, oldval, newval):
+ print 'verify: old=%s, new=%s, rec=%s'%(oldval, newval, liststore.r[rownum][colname])
+
+liststore.callbacks.connect('cell_changed', mycallback)
+
+win = gtk.Window()
+win.set_title('click to edit')
+win.add(treeview)
+win.show_all()
+win.connect('delete-event', lambda *args: gtk.main_quit())
+gtk.main()
Added: trunk/matplotlib/examples/rec_edit_gtk_simple.py
===================================================================
--- trunk/matplotlib/examples/rec_edit_gtk_simple.py	 (rev 0)
+++ trunk/matplotlib/examples/rec_edit_gtk_simple.py	2008年04月30日 19:53:10 UTC (rev 5100)
@@ -0,0 +1,15 @@
+"""
+Load a CSV file into a record array and edit it in a gtk treeview
+"""
+
+import gtk
+import numpy as np
+import matplotlib.mlab as mlab
+import mpl_toolkits.gtktools as gtktools
+
+r = mlab.csv2rec('data/demodata.csv', converterd={'weekdays':str})
+
+liststore, treeview, win = gtktools.edit_recarray(r)
+win.set_title('click to edit')
+win.connect('delete-event', lambda *args: gtk.main_quit())
+gtk.main()
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py	2008年04月29日 21:10:44 UTC (rev 5099)
+++ trunk/matplotlib/lib/matplotlib/mlab.py	2008年04月30日 19:53:10 UTC (rev 5100)
@@ -2170,7 +2170,7 @@
 data type. When set to zero all rows are validated.
 
 converterd, if not None, is a dictionary mapping column number or
- munged column name to a converter function
+ munged column name to a converter function.
 
 names, if not None, is a list of header names. In this case, no
 header will be read from the file
@@ -2256,11 +2256,18 @@
 return func(val)
 return newfunc
 
+
+ def mybool(x):
+ if x=='True': return True
+ elif x=='False': return False
+ else: raise ValueError('invalid bool')
+ 
 dateparser = dateutil.parser.parse
 mydateparser = with_default_value(dateparser, datetime.date(1,1,1))
 myfloat = with_default_value(float, np.nan)
 myint = with_default_value(int, -1)
 mystr = with_default_value(str, '')
+ mybool = with_default_value(mybool, None)
 
 def mydate(x):
 # try and return a date object
@@ -2273,7 +2280,7 @@
 
 def get_func(name, item, func):
 # promote functions in this order
- funcmap = {myint:myfloat, myfloat:mydate, mydate:mydateparser, mydateparser:mystr}
+ funcmap = {mybool:myint,myint:myfloat, myfloat:mydate, mydate:mydateparser, mydateparser:mystr}
 try: func(name, item)
 except:
 if func==mystr:
@@ -2294,7 +2301,7 @@
 converters = None
 for i, row in enumerate(reader):
 if i==0:
- converters = [myint]*len(row)
+ converters = [mybool]*len(row)
 if checkrows and i>checkrows:
 break
 #print i, len(names), len(row)
@@ -2308,6 +2315,9 @@
 func = converters[j]
 if len(item.strip()):
 func = get_func(name, item, func)
+ else:
+ # how should we handle custom converters and defaults?
+ func = with_default_value(func, None)
 converters[j] = func
 return converters
 
@@ -2427,6 +2437,13 @@
 def fromstr(self, s):
 return int(s)
 
+class FormatBool(FormatObj):
+ def toval(self, x):
+ return x
+
+ def fromstr(self, s):
+ return bool(s)
+
 class FormatPercent(FormatFloat):
 def __init__(self, precision=4):
 FormatFloat.__init__(self, precision, scale=100.)
@@ -2465,6 +2482,7 @@
 
 
 defaultformatd = {
+ np.bool_ : FormatBool(),
 np.int16 : FormatInt(),
 np.int32 : FormatInt(),
 np.int64 : FormatInt(),
Modified: trunk/matplotlib/lib/mpl_toolkits/gtktools.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/gtktools.py	2008年04月29日 21:10:44 UTC (rev 5099)
+++ trunk/matplotlib/lib/mpl_toolkits/gtktools.py	2008年04月30日 19:53:10 UTC (rev 5100)
@@ -37,6 +37,49 @@
 import matplotlib.cbook as cbook
 import matplotlib.mlab as mlab
 
+
+def error_message(msg, parent=None, title=None):
+ """
+ create an error message dialog with string msg. Optionally set
+ the parent widget and dialog title
+ """
+
+ dialog = gtk.MessageDialog(
+ parent = None,
+ type = gtk.MESSAGE_ERROR,
+ buttons = gtk.BUTTONS_OK,
+ message_format = msg)
+ if parent is not None:
+ dialog.set_transient_for(parent)
+ if title is not None:
+ dialog.set_title(title)
+ else:
+ dialog.set_title('Error!')
+ dialog.show()
+ dialog.run()
+ dialog.destroy()
+ return None
+
+def simple_message(msg, parent=None, title=None):
+ """
+ create a simple message dialog with string msg. Optionally set
+ the parent widget and dialog title
+ """
+ dialog = gtk.MessageDialog(
+ parent = None,
+ type = gtk.MESSAGE_INFO,
+ buttons = gtk.BUTTONS_OK,
+ message_format = msg)
+ if parent is not None:
+ dialog.set_transient_for(parent)
+ if title is not None:
+ dialog.set_title(title)
+ dialog.show()
+ dialog.run()
+ dialog.destroy()
+ return None
+
+
 def gtkformat_factory(format, colnum):
 """
 copy the format, perform any overrides, and attach an gtk style attrs
@@ -313,6 +356,10 @@
 
 * r - the record array with the edited values
 
+ * formatd - the list of mlab.FormatObj instances, with gtk attachments
+
+ * stringd - a dict mapping dtype names to a list of valid strings for the combo drop downs
+ 
 * callbacks - a matplotlib.cbook.CallbackRegistry. Connect to the cell_changed with
 
 def mycallback(liststore, rownum, colname, oldval, newval):
@@ -320,85 +367,265 @@
 
 cid = liststore.callbacks.connect('cell_changed', mycallback)
 
- """
- def __init__(self, r, formatd=None):
+ """
+ def __init__(self, r, formatd=None, stringd=None):
+ """
+ r is a numpy record array
+
+ formatd is a dict mapping dtype name to mlab.FormatObj instances
+
+ stringd, if not None, is a dict mapping dtype names to a list of
+ valid strings for a combo drop down editor
+ """
+ 
+ if stringd is None:
+ stringd = dict()
+ 
 if formatd is None:
 formatd = mlab.get_formatd(r)
 
+ self.stringd = stringd
 self.callbacks = cbook.CallbackRegistry(['cell_changed'])
 
 self.r = r
- gtk.ListStore.__init__(self, *([gobject.TYPE_STRING]*len(r.dtype)))
+
 self.headers = r.dtype.names
 self.formats = [gtkformat_factory(formatd.get(name, mlab.FormatObj()),i)
 for i,name in enumerate(self.headers)]
+
+ # use the gtk attached versions
+ self.formatd = formatd = dict(zip(self.headers, self.formats))
+ types = []
+ for format in self.formats:
+ if isinstance(format, mlab.FormatBool):
+ types.append(gobject.TYPE_BOOLEAN)
+ else:
+ types.append(gobject.TYPE_STRING)
+
+ self.combod = dict()
+ if len(stringd):
+ types.extend([gobject.TYPE_INT]*len(stringd))
+
+ keys = stringd.keys()
+ keys.sort()
+ 
+ valid = set(r.dtype.names)
+ for ikey, key in enumerate(keys):
+ assert(key in valid)
+ combostore = gtk.ListStore(gobject.TYPE_STRING)
+ for s in stringd[key]:
+ combostore.append([s])
+ self.combod[key] = combostore, len(self.headers)+ikey
+
+ 
+ gtk.ListStore.__init__(self, *types)
+
 for row in r:
- self.append([func.tostr(val) for func, val in zip(self.formats, row)])
+ vals = []
+ for formatter, val in zip(self.formats, row):
+ if isinstance(formatter, mlab.FormatBool):
+ vals.append(val)
+ else:
+ vals.append(formatter.tostr(val)) 
+ if len(stringd):
+ # todo, get correct index here?
+ vals.extend([0]*len(stringd))
+ self.append(vals)
 
 
 def position_edited(self, renderer, path, newtext, position):
- self[path][position] = newtext
- format = self.formats[int(position)]
 
+ position = int(position)
+ format = self.formats[position]
+
 rownum = int(path)
- colname = self.headers[int(position)]
+ colname = self.headers[position]
 oldval = self.r[rownum][colname]
- newval = format.fromstr(newtext)
+ try: newval = format.fromstr(newtext)
+ except ValueError:
+ msg = cbook.exception_to_str('Error converting "%s"'%newtext)
+ error_message(msg, title='Error')
+ return
 self.r[rownum][colname] = newval
+
+ self[path][position] = format.tostr(newval)
+
+
 self.callbacks.process('cell_changed', self, rownum, colname, oldval, newval)
 
-def editable_recarray(r, formatd=None):
+ def position_toggled(self, cellrenderer, path, position):
+ position = int(position)
+ format = self.formats[position]
+
+ newval = not cellrenderer.get_active()
+
+ rownum = int(path)
+ colname = self.headers[position]
+ oldval = self.r[rownum][colname]
+ self.r[rownum][colname] = newval
+
+ self[path][position] = newval
+
+ self.callbacks.process('cell_changed', self, rownum, colname, oldval, newval)
+
+
+
+
+
+class RecTreeView(gtk.TreeView):
 """
- return a (gtk.TreeView, RecListStore) from record array t and
- format dictionary formatd where the keys are record array dtype
- names and the values are matplotlib.mlab.FormatObj instances
+ An editable tree view widget for record arrays
+ """
+ def __init__(self, recliststore, constant=None):
+ """
+ build a gtk.TreeView to edit a RecListStore
 
- Example:
+ constant, if not None, is a list of dtype names which are not editable
+ """
+ self.recliststore = recliststore
+ 
+ gtk.TreeView.__init__(self, recliststore)
 
- formatd = mlab.get_formatd(r)
- formatd['date'] = mlab.FormatDate('%Y-%m-%d')
- formatd['volume'] = mlab.FormatMillions(precision=1)
+ combostrings = set(recliststore.stringd.keys())
 
- treeview, liststore = gtktools.editable_recarray(r, formatd=formatd)
+ 
+ if constant is None:
+ constant = []
 
- def mycallback(liststore, rownum, colname, oldval, newval):
- print 'verify: old=%s, new=%s, rec=%s'%(oldval, newval, liststore.r[rownum][colname])
+ constant = set(constant)
 
- liststore.callbacks.connect('cell_changed', mycallback)
+ for i, header in enumerate(recliststore.headers):
+ formatter = recliststore.formatd[header]
+ coltype = recliststore.get_column_type(i)
 
+ if coltype==gobject.TYPE_BOOLEAN:
+ renderer = gtk.CellRendererToggle()
+ if header not in constant:
+ renderer.connect("toggled", recliststore.position_toggled, i)
+ renderer.set_property('activatable', True)
 
+ elif header in combostrings:
+ renderer = gtk.CellRendererCombo()
+ renderer.connect("edited", recliststore.position_edited, i)
+ combostore, listind = recliststore.combod[header]
+ renderer.set_property("model", combostore)
+ renderer.set_property('editable', True) 
+ else:
+ renderer = gtk.CellRendererText()
+ if header not in constant:
+ renderer.connect("edited", recliststore.position_edited, i)
+ renderer.set_property('editable', True)
+
+
+ if formatter is not None:
+ renderer.set_property('xalign', formatter.xalign)
+
+
+
+ tvcol = gtk.TreeViewColumn(header)
+ self.append_column(tvcol)
+ tvcol.pack_start(renderer, True)
+
+ if coltype == gobject.TYPE_STRING:
+ tvcol.add_attribute(renderer, 'text', i)
+ if header in combostrings:
+ combostore, listind = recliststore.combod[header]
+ tvcol.add_attribute(renderer, 'text-column', listind) 
+ elif coltype == gobject.TYPE_BOOLEAN:
+ tvcol.add_attribute(renderer, 'active', i)
+
+
+ if formatter is not None and formatter.cell is not None:
+ tvcol.set_cell_data_func(renderer, formatter.cell)
+
+
+
+
+ self.connect("button-release-event", self.on_selection_changed)
+ self.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
+ self.get_selection().set_mode(gtk.SELECTION_BROWSE)
+ self.get_selection().set_select_function(self.on_select)
+
+
+ def on_select(self, *args):
+ return False
+
+ def on_selection_changed(self, *args):
+ (path, col) = self.get_cursor()
+ ren = col.get_cell_renderers()[0]
+ if isinstance(ren, gtk.CellRendererText):
+ self.set_cursor_on_cell(path, col, ren, start_editing=True)
+
+def edit_recarray(r, formatd=None, stringd=None, constant=None, autowin=True):
+ """
+ create a RecListStore and RecTreeView and return them.
+
+ If autowin is True, create a gtk.Window, insert the treeview into
+ it, and return it (return value will be (liststore, treeview, win)
+
+ See RecListStore and RecTreeView for a description of the keyword args
+ """
+
+ liststore = RecListStore(r, formatd=formatd, stringd=stringd)
+ treeview = RecTreeView(liststore, constant=constant)
+
+ if autowin:
 win = gtk.Window()
- win.show()
- win.connect('destroy', lambda x: gtk.main_quit())
 win.add(treeview)
- gtk.main()
+ win.show_all()
+ return liststore, treeview, win
+ else:
+ return liststore, treeview
+ 
+ 
 
- """
- liststore = RecListStore(r, formatd=formatd)
- treeview = gtk.TreeView()
- if formatd is None:
- formatd = mlab.get_formatd(r)
- for i, header in enumerate(liststore.headers):
- renderer = gtk.CellRendererText()
- renderer.connect("edited", liststore.position_edited, i)
- renderer.set_property('editable', True)
 
- formatter = gtkformat_factory(formatd.get(header), i)
+if __name__=='__main__':
 
- if formatter is not None:
- renderer.set_property('xalign', formatter.xalign)
+ import datetime
+ import gtk
+ import numpy as np
+ import matplotlib.mlab as mlab
+ N = 10
+ today = datetime.date.today()
+ dates = [today+datetime.timedelta(days=i) for i in range(N)] # datetimes
+ weekdays = [d.strftime('%a') for d in dates] # strings
+ gains = np.random.randn(N) # floats
+ prices = np.random.rand(N)*1e7 # big numbers
+ up = gains>0 # bools
+ clientid = range(N) # ints
 
- tvcol = gtk.TreeViewColumn(header)
- treeview.append_column(tvcol)
- tvcol.pack_start(renderer, True)
- tvcol.add_attribute(renderer, 'text', i)
- if formatter is not None and formatter.cell is not None:
- tvcol.set_cell_data_func(renderer, formatter.cell)
+ r = np.rec.fromarrays([clientid, dates, weekdays, gains, prices, up],
+ names='clientid,date,weekdays,gains,prices,up')
 
+ # some custom formatters
+ formatd = mlab.get_formatd(r)
+ formatd['date'] = mlab.FormatDate('%Y-%m-%d')
+ formatd['prices'] = mlab.FormatMillions(precision=1)
+ formatd['gain'] = mlab.FormatPercent(precision=2)
 
- treeview.set_model(liststore)
- treeview.show()
- treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
+ # use a drop down combo for weekdays
+ stringd = dict(weekdays=['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'])
+ constant = ['clientid'] # block editing of this field
 
 
- return treeview, liststore
+ liststore = RecListStore(r, formatd=formatd, stringd=stringd)
+ treeview = RecTreeView(liststore, constant=constant)
+
+ def mycallback(liststore, rownum, colname, oldval, newval):
+ print 'verify: old=%s, new=%s, rec=%s'%(oldval, newval, liststore.r[rownum][colname])
+
+ liststore.callbacks.connect('cell_changed', mycallback)
+
+ win = gtk.Window()
+ win.set_title('with full customization')
+ win.add(treeview)
+ win.show_all()
+
+ # or you just use the defaults
+ r2 = r.copy()
+ ls, tv, win2 = edit_recarray(r2)
+ win2.set_title('with all defaults')
+
+ gtk.main()
+ 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年04月29日 21:10:45
Revision: 5099
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5099&view=rev
Author: jdh2358
Date: 2008年04月29日 14:10:44 -0700 (2008年4月29日)
Log Message:
-----------
added support for a editable recarray widget in gtk
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/mlab.py
 trunk/matplotlib/lib/mpl_toolkits/gtktools.py
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py	2008年04月29日 15:14:36 UTC (rev 5098)
+++ trunk/matplotlib/lib/matplotlib/mlab.py	2008年04月29日 21:10:44 UTC (rev 5099)
@@ -2384,6 +2384,8 @@
 def toval(self, x):
 return str(x)
 
+ def fromstr(self, s):
+ return s
 
 class FormatString(FormatObj):
 def tostr(self, x):
@@ -2402,6 +2404,7 @@
 if x is None: return 'None'
 return self.fmt%self.toval(x)
 
+
 class FormatFloat(FormatFormatStr):
 def __init__(self, precision=4, scale=1.):
 FormatFormatStr.__init__(self, '%%1.%df'%precision)
@@ -2413,10 +2416,17 @@
 x = x * self.scale
 return x
 
+ def fromstr(self, s):
+ return float(s)/self.scale
+
+
 class FormatInt(FormatObj):
 def toval(self, x):
 return x
 
+ def fromstr(self, s):
+ return int(s)
+
 class FormatPercent(FormatFloat):
 def __init__(self, precision=4):
 FormatFloat.__init__(self, precision, scale=100.)
@@ -2425,6 +2435,7 @@
 def __init__(self, precision=4):
 FormatFloat.__init__(self, precision, scale=1e-3)
 
+
 class FormatMillions(FormatFloat):
 def __init__(self, precision=4):
 FormatFloat.__init__(self, precision, scale=1e-6)
@@ -2438,11 +2449,21 @@
 if x is None: return 'None'
 return x.strftime(self.fmt)
 
+ def fromstr(self, x):
+ import dateutil.parser
+ return dateutil.parser.parse(x).date()
+
 class FormatDatetime(FormatDate):
 def __init__(self, fmt='%Y-%m-%d %H:%M:%S'):
 FormatDate.__init__(self, fmt)
 
+ def fromstr(self, x):
+ import dateutil.parser
+ return dateutil.parser.parse(x)
 
+
+
+
 defaultformatd = {
 np.int16 : FormatInt(),
 np.int32 : FormatInt(),
Modified: trunk/matplotlib/lib/mpl_toolkits/gtktools.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/gtktools.py	2008年04月29日 15:14:36 UTC (rev 5098)
+++ trunk/matplotlib/lib/mpl_toolkits/gtktools.py	2008年04月29日 21:10:44 UTC (rev 5099)
@@ -8,7 +8,7 @@
 
 import matplotlib.mlab as mlab
 import mpl_toolkits.gtktools as gtktools
- 
+
 r = mlab.csv2rec('somefile.csv', checkrows=0)
 
 formatd = dict(
@@ -46,7 +46,7 @@
 cell = None
 
 """
-
+ if format is None: return None
 format = copy.copy(format)
 format.xalign = 0.
 format.cell = None
@@ -148,6 +148,8 @@
 
 column = gtk.TreeViewColumn(header, renderer, text=i)
 renderer.set_property('xalign', formatter.xalign)
+ renderer.set_property('editable', True)
+ renderer.connect("edited", self.position_edited, i)
 column.connect('clicked', Clicked(self, i))
 column.set_property('clickable', True)
 
@@ -164,6 +166,10 @@
 self.treeview = treeview
 self.clear()
 
+ def position_edited(self, renderer, path, newtext, position):
+ #print path, position
+ self.model[path][position] = newtext
+
 def clear(self):
 self.iterd = dict()
 self.iters = [] # an ordered list of iters
@@ -291,9 +297,108 @@
 if autowin:
 win = gtk.Window()
 win.set_default_size(800,600)
+ #win.set_geometry_hints(scroll)
 win.add(scroll)
 win.show_all()
 scroll.win = win
 
 return scroll
 
+
+class RecListStore(gtk.ListStore):
+ """
+ A liststore as a model of an editable record array.
+
+ attributes:
+
+ * r - the record array with the edited values
+
+ * callbacks - a matplotlib.cbook.CallbackRegistry. Connect to the cell_changed with
+
+ def mycallback(liststore, rownum, colname, oldval, newval):
+ print 'verify: old=%s, new=%s, rec=%s'%(oldval, newval, liststore.r[rownum][colname])
+
+ cid = liststore.callbacks.connect('cell_changed', mycallback)
+
+ """
+ def __init__(self, r, formatd=None):
+ if formatd is None:
+ formatd = mlab.get_formatd(r)
+
+ self.callbacks = cbook.CallbackRegistry(['cell_changed'])
+
+ self.r = r
+ gtk.ListStore.__init__(self, *([gobject.TYPE_STRING]*len(r.dtype)))
+ self.headers = r.dtype.names
+ self.formats = [gtkformat_factory(formatd.get(name, mlab.FormatObj()),i)
+ for i,name in enumerate(self.headers)]
+ for row in r:
+ self.append([func.tostr(val) for func, val in zip(self.formats, row)])
+
+
+ def position_edited(self, renderer, path, newtext, position):
+ self[path][position] = newtext
+ format = self.formats[int(position)]
+
+ rownum = int(path)
+ colname = self.headers[int(position)]
+ oldval = self.r[rownum][colname]
+ newval = format.fromstr(newtext)
+ self.r[rownum][colname] = newval
+ self.callbacks.process('cell_changed', self, rownum, colname, oldval, newval)
+
+def editable_recarray(r, formatd=None):
+ """
+ return a (gtk.TreeView, RecListStore) from record array t and
+ format dictionary formatd where the keys are record array dtype
+ names and the values are matplotlib.mlab.FormatObj instances
+
+ Example:
+
+ formatd = mlab.get_formatd(r)
+ formatd['date'] = mlab.FormatDate('%Y-%m-%d')
+ formatd['volume'] = mlab.FormatMillions(precision=1)
+
+ treeview, liststore = gtktools.editable_recarray(r, formatd=formatd)
+
+ def mycallback(liststore, rownum, colname, oldval, newval):
+ print 'verify: old=%s, new=%s, rec=%s'%(oldval, newval, liststore.r[rownum][colname])
+
+ liststore.callbacks.connect('cell_changed', mycallback)
+
+
+ win = gtk.Window()
+ win.show()
+ win.connect('destroy', lambda x: gtk.main_quit())
+ win.add(treeview)
+ gtk.main()
+
+ """
+ liststore = RecListStore(r, formatd=formatd)
+ treeview = gtk.TreeView()
+ if formatd is None:
+ formatd = mlab.get_formatd(r)
+ for i, header in enumerate(liststore.headers):
+ renderer = gtk.CellRendererText()
+ renderer.connect("edited", liststore.position_edited, i)
+ renderer.set_property('editable', True)
+
+ formatter = gtkformat_factory(formatd.get(header), i)
+
+ if formatter is not None:
+ renderer.set_property('xalign', formatter.xalign)
+
+ tvcol = gtk.TreeViewColumn(header)
+ treeview.append_column(tvcol)
+ tvcol.pack_start(renderer, True)
+ tvcol.add_attribute(renderer, 'text', i)
+ if formatter is not None and formatter.cell is not None:
+ tvcol.set_cell_data_func(renderer, formatter.cell)
+
+
+ treeview.set_model(liststore)
+ treeview.show()
+ treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
+
+
+ return treeview, liststore
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年04月29日 15:15:02
Revision: 5098
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5098&view=rev
Author: jdh2358
Date: 2008年04月29日 08:14:36 -0700 (2008年4月29日)
Log Message:
-----------
changed numpy abbrev from npy to np
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/art3d.py
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/axes3d.py
 trunk/matplotlib/lib/matplotlib/axis3d.py
 trunk/matplotlib/lib/matplotlib/backend_bases.py
 trunk/matplotlib/lib/matplotlib/cbook.py
 trunk/matplotlib/lib/matplotlib/cm.py
 trunk/matplotlib/lib/matplotlib/collections.py
 trunk/matplotlib/lib/matplotlib/colorbar.py
 trunk/matplotlib/lib/matplotlib/colors.py
 trunk/matplotlib/lib/matplotlib/contour.py
 trunk/matplotlib/lib/matplotlib/dates.py
 trunk/matplotlib/lib/matplotlib/dviread.py
 trunk/matplotlib/lib/matplotlib/finance.py
 trunk/matplotlib/lib/matplotlib/image.py
 trunk/matplotlib/lib/matplotlib/legend.py
 trunk/matplotlib/lib/matplotlib/lines.py
 trunk/matplotlib/lib/matplotlib/mlab.py
 trunk/matplotlib/lib/matplotlib/patches.py
 trunk/matplotlib/lib/matplotlib/path.py
 trunk/matplotlib/lib/matplotlib/proj3d.py
 trunk/matplotlib/lib/matplotlib/pylab.py
 trunk/matplotlib/lib/matplotlib/quiver.py
 trunk/matplotlib/lib/matplotlib/scale.py
 trunk/matplotlib/lib/matplotlib/texmanager.py
 trunk/matplotlib/lib/matplotlib/ticker.py
 trunk/matplotlib/lib/matplotlib/transforms.py
 trunk/matplotlib/lib/matplotlib/widgets.py
 trunk/matplotlib/setupext.py
 trunk/matplotlib/src/_backend_agg.cpp
Modified: trunk/matplotlib/lib/matplotlib/art3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/art3d.py	2008年04月29日 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/art3d.py	2008年04月29日 15:14:36 UTC (rev 5098)
@@ -11,7 +11,7 @@
 
 from colors import Normalize
 
-import numpy as npy
+import numpy as np
 import proj3d
 
 class Wrap2D:
@@ -253,8 +253,8 @@
 segis.append((si,ei))
 si = ei
 xs,ys,zs = zip(*points)
- ones = npy.ones(len(xs))
- self.vec = npy.array([xs,ys,zs,ones])
+ ones = np.ones(len(xs))
+ self.vec = np.array([xs,ys,zs,ones])
 self.segis = segis
 
 def draw3d(self, renderer):
@@ -326,7 +326,7 @@
 source = image._A
 w,h,p = source.shape
 X,Y = meshgrid(arange(w),arange(h))
- Z = npy.zeros((w,h))
+ Z = np.zeros((w,h))
 tX,tY,tZ = proj3d.transform(X.flat,Y.flat,Z.flat,M)
 tX = reshape(tX,(w,h))
 tY = reshape(tY,(w,h))
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2008年04月29日 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2008年04月29日 15:14:36 UTC (rev 5098)
@@ -1,7 +1,7 @@
 from __future__ import division, generators
 import math, warnings, new
 
-import numpy as npy
+import numpy as np
 from numpy import ma
 
 import matplotlib
@@ -212,16 +212,16 @@
 def _xy_from_y(self, y):
 if self.axes.yaxis is not None:
 b = self.axes.yaxis.update_units(y)
- if b: return npy.arange(len(y)), y, False
+ if b: return np.arange(len(y)), y, False
 
 if not ma.isMaskedArray(y):
- y = npy.asarray(y)
+ y = np.asarray(y)
 if len(y.shape) == 1:
- y = y[:,npy.newaxis]
+ y = y[:,np.newaxis]
 nr, nc = y.shape
- x = npy.arange(nr)
+ x = np.arange(nr)
 if len(x.shape) == 1:
- x = x[:,npy.newaxis]
+ x = x[:,np.newaxis]
 return x,y, True
 
 def _xy_from_xy(self, x, y):
@@ -235,18 +235,18 @@
 x = ma.asarray(x)
 y = ma.asarray(y)
 if len(x.shape) == 1:
- x = x[:,npy.newaxis]
+ x = x[:,np.newaxis]
 if len(y.shape) == 1:
- y = y[:,npy.newaxis]
+ y = y[:,np.newaxis]
 nrx, ncx = x.shape
 nry, ncy = y.shape
 assert nrx == nry, 'Dimensions of x and y are incompatible'
 if ncx == ncy:
 return x, y, True
 if ncx == 1:
- x = npy.repeat(x, ncy, axis=1)
+ x = np.repeat(x, ncy, axis=1)
 if ncy == 1:
- y = npy.repeat(y, ncx, axis=1)
+ y = np.repeat(y, ncx, axis=1)
 assert x.shape == y.shape, 'Dimensions of x and y are incompatible'
 return x, y, True
 
@@ -1231,7 +1231,7 @@
 # Otherwise, it will compute the bounds of it's current data
 # and the data in xydata
 if not ma.isMaskedArray(xys):
- xys = npy.asarray(xys)
+ xys = np.asarray(xys)
 self.dataLim.update_from_data_xy(xys, self.ignore_existing_data_limits)
 self.ignore_existing_data_limits = False
 
@@ -2071,7 +2071,7 @@
 dx = 0.5 * (dx + dy)
 dy = dx
 
- alpha = npy.power(10.0, (dx, dy))
+ alpha = np.power(10.0, (dx, dy))
 start = p.trans_inverse.transform_point((p.x, p.y))
 lim_points = p.lim.get_points()
 result = start + alpha * (lim_points - start)
@@ -2200,7 +2200,7 @@
 def dist_x_y(p1, x, y):
 'x and y are arrays; return the distance to the closest point'
 x1, y1 = p1
- return min(npy.sqrt((x-x1)**2+(y-y1)**2))
+ return min(np.sqrt((x-x1)**2+(y-y1)**2))
 
 def dist(a):
 if isinstance(a, Text):
@@ -2217,7 +2217,7 @@
 ydata = a.get_ydata(orig=False)
 xt, yt = a.get_transform().numerix_x_y(xdata, ydata)
 
- return dist_x_y(xywin, npy.asarray(xt), npy.asarray(yt))
+ return dist_x_y(xywin, np.asarray(xt), np.asarray(yt))
 
 artists = self.lines + self.patches + self.texts
 if callable(among):
@@ -2601,14 +2601,14 @@
 if not iterable(y): y = [y]
 if not iterable(xmin): xmin = [xmin]
 if not iterable(xmax): xmax = [xmax]
- y = npy.asarray(y)
- xmin = npy.asarray(xmin)
- xmax = npy.asarray(xmax)
+ y = np.asarray(y)
+ xmin = np.asarray(xmin)
+ xmax = np.asarray(xmax)
 
 if len(xmin)==1:
- xmin = npy.resize( xmin, y.shape )
+ xmin = np.resize( xmin, y.shape )
 if len(xmax)==1:
- xmax = npy.resize( xmax, y.shape )
+ xmax = np.resize( xmax, y.shape )
 
 if len(xmin)!=len(y):
 raise ValueError, 'xmin and y are unequal sized sequences'
@@ -2669,26 +2669,26 @@
 if not iterable(x): x = [x]
 if not iterable(ymin): ymin = [ymin]
 if not iterable(ymax): ymax = [ymax]
- x = npy.asarray(x)
- ymin = npy.asarray(ymin)
- ymax = npy.asarray(ymax)
+ x = np.asarray(x)
+ ymin = np.asarray(ymin)
+ ymax = np.asarray(ymax)
 if len(ymin)==1:
- ymin = npy.resize( ymin, x.shape )
+ ymin = np.resize( ymin, x.shape )
 if len(ymax)==1:
- ymax = npy.resize( ymax, x.shape )
+ ymax = np.resize( ymax, x.shape )
 
 if len(ymin)!=len(x):
 raise ValueError, 'ymin and x are unequal sized sequences'
 if len(ymax)!=len(x):
 raise ValueError, 'ymax and x are unequal sized sequences'
 
- Y = npy.array([ymin, ymax]).T
+ Y = np.array([ymin, ymax]).T
 
 verts = [ ((thisx, thisymin), (thisx, thisymax))
 for thisx, (thisymin, thisymax) in zip(x,Y)]
 #print 'creating line collection'
 coll = mcoll.LineCollection(verts, colors=colors,
- linestyles=linestyles, label=label)
+ linestyles=linestyles, label=label)
 self.add_collection(coll)
 coll.update(kwargs)
 
@@ -3063,19 +3063,19 @@
 if Nx!=len(y):
 raise ValueError('x and y must be equal length')
 
- x = detrend(npy.asarray(x))
- y = detrend(npy.asarray(y))
+ x = detrend(np.asarray(x))
+ y = detrend(np.asarray(y))
 
- c = npy.correlate(x, y, mode=2)
+ c = np.correlate(x, y, mode=2)
 
- if normed: c/= npy.sqrt(npy.dot(x,x) * npy.dot(y,y))
+ if normed: c/= np.sqrt(np.dot(x,x) * np.dot(y,y))
 
 if maxlags is None: maxlags = Nx - 1
 
 if maxlags >= Nx or maxlags < 1:
 raise ValueError('maglags must be None or strictly positive < %d'%Nx)
 
- lags = npy.arange(-maxlags,maxlags+1)
+ lags = np.arange(-maxlags,maxlags+1)
 c = c[Nx-1-maxlags:Nx+maxlags]
 
 
@@ -3358,10 +3358,10 @@
 
 
 # do not convert to array here as unit info is lost
- #left = npy.asarray(left)
- #height = npy.asarray(height)
- #width = npy.asarray(width)
- #bottom = npy.asarray(bottom)
+ #left = np.asarray(left)
+ #height = np.asarray(height)
+ #width = np.asarray(width)
+ #bottom = np.asarray(bottom)
 
 if len(linewidth) == 1: linewidth = linewidth * nbars
 
@@ -3469,16 +3469,16 @@
 
 if adjust_xlim:
 xmin, xmax = self.dataLim.intervalx
- xmin = npy.amin(width)
+ xmin = np.amin(width)
 if xerr is not None:
- xmin = xmin - npy.amax(xerr)
+ xmin = xmin - np.amax(xerr)
 xmin = max(xmin*0.9, 1e-100)
 self.dataLim.intervalx = (xmin, xmax)
 if adjust_ylim:
 ymin, ymax = self.dataLim.intervaly
- ymin = npy.amin(height)
+ ymin = np.amin(height)
 if yerr is not None:
- ymin = ymin - npy.amax(yerr)
+ ymin = ymin - np.amax(yerr)
 ymin = max(ymin*0.9, 1e-100)
 self.dataLim.intervaly = (ymin, ymax)
 self.autoscale_view()
@@ -3596,7 +3596,7 @@
 l, = self.plot([thisx,thisx], [0, thisy], linefmt)
 stemlines.append(l)
 
- baseline, = self.plot([npy.amin(x), npy.amax(x)], [0,0], basefmt)
+ baseline, = self.plot([np.amin(x), np.amax(x)], [0,0], basefmt)
 
 self.hold(remember_hold)
 
@@ -3658,10 +3658,10 @@
 """
 self.set_frame_on(False)
 
- x = npy.asarray(x).astype(npy.float32)
+ x = np.asarray(x).astype(np.float32)
 
 sx = float(x.sum())
- if sx>1: x = npy.divide(x,sx)
+ if sx>1: x = np.divide(x,sx)
 
 if labels is None: labels = ['']*len(x)
 if explode is None: explode = [0]*len(x)
@@ -3841,17 +3841,17 @@
 
 # arrays fine here, they are booleans and hence not units
 if not iterable(lolims):
- lolims = npy.asarray([lolims]*len(x), bool)
- else: lolims = npy.asarray(lolims, bool)
+ lolims = np.asarray([lolims]*len(x), bool)
+ else: lolims = np.asarray(lolims, bool)
 
- if not iterable(uplims): uplims = npy.array([uplims]*len(x), bool)
- else: uplims = npy.asarray(uplims, bool)
+ if not iterable(uplims): uplims = np.array([uplims]*len(x), bool)
+ else: uplims = np.asarray(uplims, bool)
 
- if not iterable(xlolims): xlolims = npy.array([xlolims]*len(x), bool)
- else: xlolims = npy.asarray(xlolims, bool)
+ if not iterable(xlolims): xlolims = np.array([xlolims]*len(x), bool)
+ else: xlolims = np.asarray(xlolims, bool)
 
- if not iterable(xuplims): xuplims = npy.array([xuplims]*len(x), bool)
- else: xuplims = npy.asarray(xuplims, bool)
+ if not iterable(xuplims): xuplims = np.array([xuplims]*len(x), bool)
+ else: xuplims = np.asarray(xuplims, bool)
 
 def xywhere(xs, ys, mask):
 """
@@ -4032,26 +4032,26 @@
 distance = max(positions) - min(positions)
 widths = min(0.15*max(distance,1.0), 0.5)
 if isinstance(widths, float) or isinstance(widths, int):
- widths = npy.ones((col,), float) * widths
+ widths = np.ones((col,), float) * widths
 
 # loop through columns, adding each to plot
 self.hold(True)
 for i,pos in enumerate(positions):
- d = npy.ravel(x[i])
+ d = np.ravel(x[i])
 row = len(d)
 # get median and quartiles
 q1, med, q3 = mlab.prctile(d,[25,50,75])
 # get high extreme
 iq = q3 - q1
 hi_val = q3 + whis*iq
- wisk_hi = npy.compress( d <= hi_val , d )
+ wisk_hi = np.compress( d <= hi_val , d )
 if len(wisk_hi) == 0:
 wisk_hi = q3
 else:
 wisk_hi = max(wisk_hi)
 # get low extreme
 lo_val = q1 - whis*iq
- wisk_lo = npy.compress( d >= lo_val, d )
+ wisk_lo = np.compress( d >= lo_val, d )
 if len(wisk_lo) == 0:
 wisk_lo = q1
 else:
@@ -4062,16 +4062,16 @@
 flier_hi_x = []
 flier_lo_x = []
 if len(sym) != 0:
- flier_hi = npy.compress( d > wisk_hi, d )
- flier_lo = npy.compress( d < wisk_lo, d )
- flier_hi_x = npy.ones(flier_hi.shape[0]) * pos
- flier_lo_x = npy.ones(flier_lo.shape[0]) * pos
+ flier_hi = np.compress( d > wisk_hi, d )
+ flier_lo = np.compress( d < wisk_lo, d )
+ flier_hi_x = np.ones(flier_hi.shape[0]) * pos
+ flier_lo_x = np.ones(flier_lo.shape[0]) * pos
 
 # get x locations for fliers, whisker, whisker cap and box sides
 box_x_min = pos - widths[i] * 0.5
 box_x_max = pos + widths[i] * 0.5
 
- wisk_x = npy.ones(2) * pos
+ wisk_x = np.ones(2) * pos
 
 cap_x_min = pos - widths[i] * 0.25
 cap_x_max = pos + widths[i] * 0.25
@@ -4089,8 +4089,8 @@
 med_x = [box_x_min, box_x_max]
 # calculate 'notch' plot
 else:
- notch_max = med + 1.57*iq/npy.sqrt(row)
- notch_min = med - 1.57*iq/npy.sqrt(row)
+ notch_max = med + 1.57*iq/np.sqrt(row)
+ notch_min = med - 1.57*iq/np.sqrt(row)
 if notch_max > q3:
 notch_max = q3
 if notch_min < q1:
@@ -4267,7 +4267,7 @@
 # mapping, not interpretation as rgb or rgba.
 
 if not is_string_like(c):
- sh = npy.shape(c)
+ sh = np.shape(c)
 if len(sh) == 1 and sh[0] == len(x):
 colors = None # use cmap, norm after collection is created
 else:
@@ -4324,7 +4324,7 @@
 symstyle = marker[1]
 
 else:
- verts = npy.asarray(marker[0])
+ verts = np.asarray(marker[0])
 
 if sym is not None:
 if symstyle==0:
@@ -4357,11 +4357,11 @@
 else:
 # MGDTODO: This has dpi problems
 # rescale verts
- rescale = npy.sqrt(max(verts[:,0]**2+verts[:,1]**2))
+ rescale = np.sqrt(max(verts[:,0]**2+verts[:,1]**2))
 verts /= rescale
 
- scales = npy.asarray(scales)
- scales = npy.sqrt(scales * self.figure.dpi / 72.)
+ scales = np.asarray(scales)
+ scales = np.sqrt(scales * self.figure.dpi / 72.)
 if len(scales)==1:
 verts = [scales[0]*verts]
 else:
@@ -4382,7 +4382,7 @@
 if colors is None:
 if norm is not None: assert(isinstance(norm, mcolors.Normalize))
 if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))
- collection.set_array(npy.asarray(c))
+ collection.set_array(np.asarray(c))
 collection.set_cmap(cmap)
 collection.set_norm(norm)
 
@@ -4394,10 +4394,10 @@
 temp_x = x
 temp_y = y
 
- minx = npy.amin(temp_x)
- maxx = npy.amax(temp_x)
- miny = npy.amin(temp_y)
- maxy = npy.amax(temp_y)
+ minx = np.amin(temp_x)
+ maxx = np.amax(temp_x)
+ miny = np.amin(temp_y)
+ maxy = np.amax(temp_y)
 
 w = maxx-minx
 h = maxy-miny
@@ -4513,16 +4513,16 @@
 nx = gridsize
 ny = int(nx/math.sqrt(3))
 # Count the number of data in each hexagon
- x = npy.array(x, float)
- y = npy.array(y, float)
+ x = np.array(x, float)
+ y = np.array(y, float)
 if xscale=='log':
- x = npy.log10(x)
+ x = np.log10(x)
 if yscale=='log':
- y = npy.log10(y)
- xmin = npy.amin(x)
- xmax = npy.amax(x)
- ymin = npy.amin(y)
- ymax = npy.amax(y)
+ y = np.log10(y)
+ xmin = np.amin(x)
+ xmax = np.amax(x)
+ ymin = np.amin(y)
+ ymax = np.amax(y)
 # In the x-direction, the hexagons exactly cover the region from
 # xmin to xmax. Need some padding to avoid roundoff errors.
 padding = 1.e-9 * (xmax - xmin)
@@ -4532,17 +4532,17 @@
 sy = (ymax-ymin) / ny
 x = (x-xmin)/sx
 y = (y-ymin)/sy
- ix1 = npy.round(x).astype(int)
- iy1 = npy.round(y).astype(int)
- ix2 = npy.floor(x).astype(int)
- iy2 = npy.floor(y).astype(int)
+ ix1 = np.round(x).astype(int)
+ iy1 = np.round(y).astype(int)
+ ix2 = np.floor(x).astype(int)
+ iy2 = np.floor(y).astype(int)
 
 nx1 = nx + 1
 ny1 = ny + 1
 nx2 = nx
 ny2 = ny
 n = nx1*ny1+nx2*ny2
- counts = npy.zeros(n)
+ counts = np.zeros(n)
 lattice1 = counts[:nx1*ny1]
 lattice2 = counts[nx1*ny1:]
 lattice1.shape = (nx1,ny1)
@@ -4558,16 +4558,16 @@
 else:
 lattice2[ix2[i], iy2[i]]+=1
 
- px = xmin + sx * npy.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0])
- py = ymin + sy * npy.array([-0.5, 0.5, 1.0, 0.5, -0.5, -1.0]) / 3.0
+ px = xmin + sx * np.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0])
+ py = ymin + sy * np.array([-0.5, 0.5, 1.0, 0.5, -0.5, -1.0]) / 3.0
 
- polygons = npy.zeros((6, n, 2), float)
- polygons[:,:nx1*ny1,0] = npy.repeat(npy.arange(nx1), ny1)
- polygons[:,:nx1*ny1,1] = npy.tile(npy.arange(ny1), nx1)
- polygons[:,nx1*ny1:,0] = npy.repeat(npy.arange(nx2) + 0.5, ny2)
- polygons[:,nx1*ny1:,1] = npy.tile(npy.arange(ny2), nx2) + 0.5
+ polygons = np.zeros((6, n, 2), float)
+ polygons[:,:nx1*ny1,0] = np.repeat(np.arange(nx1), ny1)
+ polygons[:,:nx1*ny1,1] = np.tile(np.arange(ny1), nx1)
+ polygons[:,nx1*ny1:,0] = np.repeat(np.arange(nx2) + 0.5, ny2)
+ polygons[:,nx1*ny1:,1] = np.tile(np.arange(ny2), nx2) + 0.5
 
- polygons = npy.transpose(polygons, axes=[1,0,2])
+ polygons = np.transpose(polygons, axes=[1,0,2])
 polygons[:,:,0] *= sx
 polygons[:,:,1] *= sy
 polygons[:,:,0] += px
@@ -4607,13 +4607,13 @@
 
 # Transform the counts if needed
 if bins=='log':
- counts = npy.log10(counts+1)
+ counts = np.log10(counts+1)
 elif bins!=None:
 if not iterable(bins):
 minimum, maximum = min(counts), max(counts)
 bins-=1 # one less edge than bins
- bins = minimum + (maximum-minimum)*npy.arange(bins)/bins
- bins = npy.sort(bins)
+ bins = minimum + (maximum-minimum)*np.arange(bins)/bins
+ bins = np.sort(bins)
 counts = bins.searchsorted(counts)
 
 if norm is not None: assert(isinstance(norm, mcolors.Normalize))
@@ -4847,7 +4847,7 @@
 if len(args)==1:
 C = args[0]
 numRows, numCols = C.shape
- X, Y = npy.meshgrid(npy.arange(numCols+1), npy.arange(numRows+1) )
+ X, Y = np.meshgrid(np.arange(numCols+1), np.arange(numRows+1) )
 elif len(args)==3:
 X, Y, C = args
 else:
@@ -4936,8 +4936,8 @@
 
 Similarly for meshgrid:
 
- x = npy.arange(5)
- y = npy.arange(3)
+ x = np.arange(5)
+ y = np.arange(3)
 X, Y = meshgrid(x,y)
 
 is equivalent to
@@ -4990,8 +4990,8 @@
 # don't plot if C or any of the surrounding vertices are masked.
 mask = ma.getmaskarray(C)[0:Ny-1,0:Nx-1]+xymask
 
- newaxis = npy.newaxis
- compress = npy.compress
+ newaxis = np.newaxis
+ compress = np.compress
 
 ravelmask = (mask==0).ravel()
 X1 = compress(ravelmask, ma.filled(X[0:-1,0:-1]).ravel())
@@ -5004,7 +5004,7 @@
 Y4 = compress(ravelmask, ma.filled(Y[0:-1,1:]).ravel())
 npoly = len(X1)
 
- xy = npy.concatenate((X1[:,newaxis], Y1[:,newaxis],
+ xy = np.concatenate((X1[:,newaxis], Y1[:,newaxis],
 X2[:,newaxis], Y2[:,newaxis],
 X3[:,newaxis], Y3[:,newaxis],
 X4[:,newaxis], Y4[:,newaxis],
@@ -5043,10 +5043,10 @@
 
 x = X.compressed()
 y = Y.compressed()
- minx = npy.amin(x)
- maxx = npy.amax(x)
- miny = npy.amin(y)
- maxy = npy.amax(y)
+ minx = np.amin(x)
+ maxx = np.amax(x)
+ miny = np.amin(y)
+ maxy = np.amax(y)
 
 corners = (minx, miny), (maxx, maxy)
 self.update_datalim( corners)
@@ -5127,7 +5127,7 @@
 X = X.ravel()
 Y = Y.ravel()
 
- coords = npy.zeros(((Nx * Ny), 2), dtype=float)
+ coords = np.zeros(((Nx * Ny), 2), dtype=float)
 coords[:, 0] = X
 coords[:, 1] = Y
 
@@ -5151,10 +5151,10 @@
 
 self.grid(False)
 
- minx = npy.amin(X)
- maxx = npy.amax(X)
- miny = npy.amin(Y)
- maxy = npy.amax(Y)
+ minx = np.amin(X)
+ maxx = np.amax(X)
+ miny = np.amin(Y)
+ maxy = np.amax(Y)
 
 corners = (minx, miny), (maxx, maxy)
 self.update_datalim( corners)
@@ -5250,16 +5250,16 @@
 y = [0, nr]
 elif len(args) == 3:
 x, y = args[:2]
- x = npy.asarray(x)
- y = npy.asarray(y)
+ x = np.asarray(x)
+ y = np.asarray(y)
 if x.ndim == 1 and y.ndim == 1:
 if x.size == 2 and y.size == 2:
 style = "image"
 else:
- dx = npy.diff(x)
- dy = npy.diff(y)
- if (npy.ptp(dx) < 0.01*npy.abs(dx.mean()) and
- npy.ptp(dy) < 0.01*npy.abs(dy.mean())):
+ dx = np.diff(x)
+ dy = np.diff(y)
+ if (np.ptp(dx) < 0.01*np.abs(dx.mean()) and
+ np.ptp(dy) < 0.01*np.abs(dy.mean())):
 style = "image"
 else:
 style = "pcolorimage"
@@ -5283,7 +5283,7 @@
 # The following needs to be cleaned up; the renderer
 # requires separate contiguous arrays for X and Y,
 # but the QuadMesh class requires the 2D array.
- coords = npy.empty(((Nx * Ny), 2), npy.float64)
+ coords = np.empty(((Nx * Ny), 2), np.float64)
 coords[:, 0] = X
 coords[:, 1] = Y
 
@@ -5328,7 +5328,7 @@
 ret.set_clim(vmin, vmax)
 else:
 ret.autoscale_None()
- self.update_datalim(npy.array([[xl, yb], [xr, yt]]))
+ self.update_datalim(np.array([[xl, yb], [xr, yt]]))
 self.autoscale_view(tight=True)
 return ret
 
@@ -5427,7 +5427,7 @@
 
 # trapezoidal integration of the probability density function
 pdf, bins, patches = ax.hist(...)
- print npy.trapz(pdf, bins)
+ print np.trapz(pdf, bins)
 
 align = 'edge' | 'center'. Interprets bins either as edge
 or center values
@@ -5445,7 +5445,7 @@
 %(Rectangle)s
 """
 if not self._hold: self.cla()
- n, bins = npy.histogram(x, bins, range=None, normed=normed)
+ n, bins = np.histogram(x, bins, range=None, normed=normed)
 if width is None: width = 0.9*(bins[1]-bins[0])
 if orientation == 'horizontal':
 patches = self.barh(bins, n, height=width, left=bottom,
@@ -5498,7 +5498,7 @@
 
 Returns the tuple Pxx, freqs
 
- For plotting, the power is plotted as 10*npy.log10(pxx) for decibels,
+ For plotting, the power is plotted as 10*np.log10(pxx) for decibels,
 though pxx itself is returned
 
 Refs:
@@ -5514,17 +5514,17 @@
 pxx.shape = len(freqs),
 freqs += Fc
 
- self.plot(freqs, 10*npy.log10(pxx), **kwargs)
+ self.plot(freqs, 10*np.log10(pxx), **kwargs)
 self.set_xlabel('Frequency')
 self.set_ylabel('Power Spectrum (dB)')
 self.grid(True)
 vmin, vmax = self.viewLim.intervaly
 intv = vmax-vmin
- logi = int(npy.log10(intv))
+ logi = int(np.log10(intv))
 if logi==0: logi=.1
 step = 10*logi
 #print vmin, vmax, step, intv, math.floor(vmin), math.ceil(vmax)+1
- ticks = npy.arange(math.floor(vmin), math.ceil(vmax)+1, step)
+ ticks = np.arange(math.floor(vmin), math.ceil(vmax)+1, step)
 self.set_yticks(ticks)
 
 return pxx, freqs
@@ -5546,7 +5546,7 @@
 See the PSD help for a description of the optional parameters.
 
 Returns the tuple Pxy, freqs. Pxy is the cross spectrum (complex
- valued), and 10*npy.log10(|Pxy|) is plotted
+ valued), and 10*np.log10(|Pxy|) is plotted
 
 Refs:
 Bendat & Piersol -- Random Data: Analysis and Measurement
@@ -5561,16 +5561,16 @@
 # pxy is complex
 freqs += Fc
 
- self.plot(freqs, 10*npy.log10(npy.absolute(pxy)), **kwargs)
+ self.plot(freqs, 10*np.log10(np.absolute(pxy)), **kwargs)
 self.set_xlabel('Frequency')
 self.set_ylabel('Cross Spectrum Magnitude (dB)')
 self.grid(True)
 vmin, vmax = self.viewLim.intervaly
 
 intv = vmax-vmin
- step = 10*int(npy.log10(intv))
+ step = 10*int(np.log10(intv))
 
- ticks = npy.arange(math.floor(vmin), math.ceil(vmax)+1, step)
+ ticks = np.arange(math.floor(vmin), math.ceil(vmax)+1, step)
 self.set_yticks(ticks)
 
 return pxy, freqs
@@ -5655,10 +5655,10 @@
 window, noverlap)
 
 
- Z = 10*npy.log10(Pxx)
- Z = npy.flipud(Z)
+ Z = 10*np.log10(Pxx)
+ Z = np.flipud(Z)
 
- if xextent is None: xextent = 0, npy.amax(bins)
+ if xextent is None: xextent = 0, np.amax(bins)
 xmin, xmax = xextent
 freqs += Fc
 extent = xmin, xmax, freqs[0], freqs[-1]
@@ -5718,9 +5718,9 @@
 if marker is None and markersize is None:
 if hasattr(Z, 'tocoo'):
 raise TypeError, "Image mode does not support scipy.sparse arrays"
- Z = npy.asarray(Z)
+ Z = np.asarray(Z)
 if precision is None: mask = Z!=0.
- else: mask = npy.absolute(Z)>precision
+ else: mask = np.absolute(Z)>precision
 
 if 'cmap' not in kwargs:
 kwargs['cmap'] = mcolors.ListedColormap(['w', 'k'], name='binary')
@@ -5735,9 +5735,9 @@
 x = c.col
 z = c.data
 else:
- Z = npy.asarray(Z)
+ Z = np.asarray(Z)
 if precision is None: mask = Z!=0.
- else: mask = npy.absolute(Z)>precision
+ else: mask = np.absolute(Z)>precision
 y,x,z = mlab.get_xyz_where(mask, mask)
 if marker is None: marker = 's'
 if markersize is None: markersize = 10
@@ -5780,7 +5780,7 @@
 Returns: an image.AxesImage instance
 
 '''
- Z = npy.asarray(Z)
+ Z = np.asarray(Z)
 nr, nc = Z.shape
 extent = [-0.5, nc-0.5, nr-0.5, -0.5]
 kw = {'extent': extent,
Modified: trunk/matplotlib/lib/matplotlib/axes3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes3d.py	2008年04月29日 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/axes3d.py	2008年04月29日 15:14:36 UTC (rev 5098)
@@ -15,7 +15,7 @@
 import cbook
 from transforms import unit_bbox
 
-import numpy as npy
+import numpy as np
 from colors import Normalize
 
 import art3d
@@ -184,7 +184,7 @@
 pass
 
 def auto_scale_xyz(self, X,Y,Z=None,had_data=None):
- x,y,z = map(npy.asarray, (X,Y,Z))
+ x,y,z = map(np.asarray, (X,Y,Z))
 try:
 x,y = X.flat,Y.flat
 if Z is not None:
@@ -274,7 +274,7 @@
 point.
 
 """
- relev,razim = npy.pi * self.elev/180, npy.pi * self.azim/180
+ relev,razim = np.pi * self.elev/180, np.pi * self.azim/180
 
 xmin,xmax = self.get_w_xlim()
 ymin,ymax = self.get_w_ylim()
@@ -286,29 +286,29 @@
 zmin,zmax)
 
 # look into the middle of the new coordinates
- R = npy.array([0.5,0.5,0.5])
+ R = np.array([0.5,0.5,0.5])
 #
- xp = R[0] + npy.cos(razim)*npy.cos(relev)*self.dist
- yp = R[1] + npy.sin(razim)*npy.cos(relev)*self.dist
- zp = R[2] + npy.sin(relev)*self.dist
+ xp = R[0] + np.cos(razim)*np.cos(relev)*self.dist
+ yp = R[1] + np.sin(razim)*np.cos(relev)*self.dist
+ zp = R[2] + np.sin(relev)*self.dist
 
- E = npy.array((xp, yp, zp))
+ E = np.array((xp, yp, zp))
 #
 self.eye = E
 self.vvec = R - E
 self.vvec = self.vvec / proj3d.mod(self.vvec)
 
- if abs(relev) > npy.pi/2:
+ if abs(relev) > np.pi/2:
 # upside down
- V = npy.array((0,0,-1))
+ V = np.array((0,0,-1))
 else:
- V = npy.array((0,0,1))
+ V = np.array((0,0,1))
 zfront,zback = -self.dist,self.dist
 
 viewM = proj3d.view_transformation(E,R,V)
 perspM = proj3d.persp_transformation(zfront,zback)
- M0 = npy.dot(viewM,worldM)
- M = npy.dot(perspM,M0)
+ M0 = np.dot(viewM,worldM)
+ M = np.dot(perspM,M0)
 return M
 
 def mouse_init(self):
@@ -382,8 +382,8 @@
 # scale the z value to match
 x0,y0,z0 = p0
 x1,y1,z1 = p1
- d0 = npy.hypot(x0-xd,y0-yd)
- d1 = npy.hypot(x1-xd,y1-yd)
+ d0 = np.hypot(x0-xd,y0-yd)
+ d1 = np.hypot(x1-xd,y1-yd)
 dt = d0+d1
 z = d1/dt * z0 + d0/dt * z1
 #print 'mid', edgei, d0, d1, z0, z1, z
@@ -503,14 +503,14 @@
 had_data = self.has_data()
 
 rows, cols = Z.shape
- tX,tY,tZ = npy.transpose(X), npy.transpose(Y), npy.transpose(Z)
+ tX,tY,tZ = np.transpose(X), np.transpose(Y), np.transpose(Z)
 rstride = cbook.popd(kwargs, 'rstride', 10)
 cstride = cbook.popd(kwargs, 'cstride', 10)
 #
 polys = []
 boxes = []
- for rs in npy.arange(0,rows-1,rstride):
- for cs in npy.arange(0,cols-1,cstride):
+ for rs in np.arange(0,rows-1,rstride):
+ for cs in np.arange(0,cols-1,cstride):
 ps = []
 corners = []
 for a,ta in [(X,tX),(Y,tY),(Z,tZ)]:
@@ -521,9 +521,9 @@
 zright = ta[cs][rs:min(rows,rs+rstride+1):]
 zright = zright[::-1]
 corners.append([ztop[0],ztop[-1],zbase[0],zbase[-1]])
- z = npy.concatenate((ztop,zleft,zbase,zright))
+ z = np.concatenate((ztop,zleft,zbase,zright))
 ps.append(z)
- boxes.append(map(npy.array,zip(*corners)))
+ boxes.append(map(np.array,zip(*corners)))
 polys.append(zip(*ps))
 #
 lines = []
@@ -532,10 +532,10 @@
 n = proj3d.cross(box[0]-box[1],
 box[0]-box[2])
 n = n/proj3d.mod(n)*5
- shade.append(npy.dot(n,[-1,-1,0.5]))
+ shade.append(np.dot(n,[-1,-1,0.5]))
 lines.append((box[0],n+box[0]))
 #
- color = npy.array([0,0,1,1])
+ color = np.array([0,0,1,1])
 norm = Normalize(min(shade),max(shade))
 colors = [color * (0.5+norm(v)*0.5) for v in shade]
 for c in colors: c[3] = 1
@@ -553,7 +553,7 @@
 had_data = self.has_data()
 rows,cols = Z.shape
 
- tX,tY,tZ = npy.transpose(X), npy.transpose(Y), npy.transpose(Z)
+ tX,tY,tZ = np.transpose(X), np.transpose(Y), np.transpose(Z)
 
 rii = [i for i in range(0,rows,rstride)]+[rows-1]
 cii = [i for i in range(0,cols,cstride)]+[cols-1]
@@ -718,8 +718,8 @@
 
 def get_test_data(delta=0.05):
 from mlab import bivariate_normal
- x = y = npy.arange(-3.0, 3.0, delta)
- X, Y = npy.meshgrid(x,y)
+ x = y = np.arange(-3.0, 3.0, delta)
+ X, Y = np.meshgrid(x,y)
 
 Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
 Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
@@ -764,8 +764,8 @@
 
 def test_plot():
 ax = Axes3D()
- xs = npy.arange(0,4*npy.pi+0.1,0.1)
- ys = npy.sin(xs)
+ xs = np.arange(0,4*np.pi+0.1,0.1)
+ ys = np.sin(xs)
 ax.plot(xs,ys, label='zl')
 ax.plot(xs,ys+max(xs),label='zh')
 ax.plot(xs,ys,dir='x', label='xl')
@@ -785,7 +785,7 @@
 cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6)
 
 ax = Axes3D()
- xs = npy.arange(0,10,0.4)
+ xs = np.arange(0,10,0.4)
 verts = []
 zs = [0.0,1.0,2.0,3.0]
 for z in zs:
@@ -817,7 +817,7 @@
 ax = Axes3D()
 
 for c,z in zip(['r','g','b','y'],[30,20,10,0]):
- xs = npy.arange(20)
+ xs = np.arange(20)
 ys = [random.random() for x in xs]
 ax.bar(xs,ys,z=z,dir='y',color=c)
 #ax.plot(xs,ys)
Modified: trunk/matplotlib/lib/matplotlib/axis3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axis3d.py	2008年04月29日 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/axis3d.py	2008年04月29日 15:14:36 UTC (rev 5098)
@@ -13,7 +13,7 @@
 import art3d
 import proj3d
 
-import numpy as npy
+import numpy as np
 
 def norm_angle(a):
 """Return angle between -180 and +180"""
@@ -51,8 +51,8 @@
 
 # Compute the dash end points
 # The 'c' prefix is for canvas coordinates
- cxy = npy.array(transform.xy_tup((x, y)))
- cd = npy.array([cos_theta, sin_theta])
+ cxy = np.array(transform.xy_tup((x, y)))
+ cd = np.array([cos_theta, sin_theta])
 c1 = cxy+dashpush*cd
 c2 = cxy+(dashpush+dashlength)*cd
 (x1, y1) = transform.inverse_xy_tup(tuple(c1))
@@ -75,9 +75,9 @@
 # well enough yet.
 we = self._mytext.get_window_extent(renderer=renderer)
 w, h = we.width(), we.height()
- off = npy.array([cos_theta*(w/2+2)-1,sin_theta*(h+1)-1])
- off = npy.array([cos_theta*(w/2),sin_theta*(h/2)])
- dir = npy.array([cos_theta,sin_theta])*dashpad
+ off = np.array([cos_theta*(w/2+2)-1,sin_theta*(h+1)-1])
+ off = np.array([cos_theta*(w/2),sin_theta*(h/2)])
+ dir = np.array([cos_theta,sin_theta])*dashpad
 cw = c2 + off +dir
 
 self._mytext.set_position(transform.inverse_xy_tup(tuple(cw)))
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py	2008年04月29日 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py	2008年04月29日 15:14:36 UTC (rev 5098)
@@ -6,7 +6,7 @@
 from __future__ import division
 import os
 
-import numpy as npy
+import numpy as np
 import matplotlib.cbook as cbook
 import matplotlib.colors as colors
 import matplotlib._image as _image
@@ -122,10 +122,10 @@
 meshWidth, meshHeight, coordinates)
 
 if showedges:
- edgecolors = npy.array([[0.0, 0.0, 0.0, 1.0]], npy.float_)
+ edgecolors = np.array([[0.0, 0.0, 0.0, 1.0]], np.float_)
 else:
 edgecolors = facecolors
- linewidths = npy.array([1.0], npy.float_)
+ linewidths = np.array([1.0], np.float_)
 
 return self.draw_path_collection(
 master_transform, cliprect, clippath, clippath_trans,
@@ -1569,7 +1569,7 @@
 a.set_ylim((y0, y1))
 elif self._button_pressed == 3:
 if a.get_xscale()=='log':
- alpha=npy.log(Xmax/Xmin)/npy.log(x1/x0)
+ alpha=np.log(Xmax/Xmin)/np.log(x1/x0)
 rx1=pow(Xmin/x0,alpha)*Xmin
 rx2=pow(Xmax/x0,alpha)*Xmin
 else:
@@ -1577,7 +1577,7 @@
 rx1=alpha*(Xmin-x0)+Xmin
 rx2=alpha*(Xmax-x0)+Xmin
 if a.get_yscale()=='log':
- alpha=npy.log(Ymax/Ymin)/npy.log(y1/y0)
+ alpha=np.log(Ymax/Ymin)/np.log(y1/y0)
 ry1=pow(Ymin/y0,alpha)*Ymin
 ry2=pow(Ymax/y0,alpha)*Ymin
 else:
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py	2008年04月29日 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/cbook.py	2008年04月29日 15:14:36 UTC (rev 5098)
@@ -5,7 +5,7 @@
 from __future__ import generators
 import re, os, errno, sys, StringIO, traceback, locale
 import time, datetime
-import numpy as npy
+import numpy as np
 
 try:
 set = set
@@ -856,7 +856,7 @@
 class MemoryMonitor:
 def __init__(self, nmax=20000):
 self._nmax = nmax
- self._mem = npy.zeros((self._nmax,), npy.int32)
+ self._mem = np.zeros((self._nmax,), np.int32)
 self.clear()
 
 def clear(self):
@@ -892,7 +892,7 @@
 print "Warning: array size was too small for the number of calls."
 
 def xy(self, i0=0, isub=1):
- x = npy.arange(i0, self._n, isub)
+ x = np.arange(i0, self._n, isub)
 return x, self._mem[i0:self._n:isub]
 
 def plot(self, i0=0, isub=1, fig=None):
@@ -1051,11 +1051,11 @@
 
 
 def simple_linear_interpolation(a, steps):
- steps = npy.floor(steps)
+ steps = np.floor(steps)
 new_length = ((len(a) - 1) * steps) + 1
 new_shape = list(a.shape)
 new_shape[0] = new_length
- result = npy.zeros(new_shape, a.dtype)
+ result = np.zeros(new_shape, a.dtype)
 
 result[0] = a[0]
 a0 = a[0:-1]
Modified: trunk/matplotlib/lib/matplotlib/cm.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cm.py	2008年04月29日 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/cm.py	2008年04月29日 15:14:36 UTC (rev 5098)
@@ -2,7 +2,7 @@
 This module contains the instantiations of color mapping classes
 """
 
-import numpy as npy
+import numpy as np
 from numpy import ma
 import matplotlib as mpl
 import matplotlib.colors as colors
@@ -56,18 +56,18 @@
 try:
 if x.ndim == 3:
 if x.shape[2] == 3:
- if x.dtype == npy.uint8:
- alpha = npy.array(alpha*255, npy.uint8)
+ if x.dtype == np.uint8:
+ alpha = np.array(alpha*255, np.uint8)
 m, n = x.shape[:2]
- xx = npy.empty(shape=(m,n,4), dtype = x.dtype)
+ xx = np.empty(shape=(m,n,4), dtype = x.dtype)
 xx[:,:,:3] = x
 xx[:,:,3] = alpha
 elif x.shape[2] == 4:
 xx = x
 else:
 raise ValueError("third dimension must be 3 or 4")
- if bytes and xx.dtype != npy.uint8:
- xx = (xx * 255).astype(npy.uint8)
+ if bytes and xx.dtype != np.uint8:
+ xx = (xx * 255).astype(np.uint8)
 return xx
 except AttributeError:
 pass
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py	2008年04月29日 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/collections.py	2008年04月29日 15:14:36 UTC (rev 5098)
@@ -8,7 +8,7 @@
 line segemnts)
 """
 import math, warnings
-import numpy as npy
+import numpy as np
 import matplotlib as mpl
 import matplotlib.cbook as cbook
 import matplotlib.colors as _colors # avoid conflict with kwarg
@@ -51,7 +51,7 @@
 draw time a call to scalar mappable will be made to set the face
 colors.
 """
- _offsets = npy.array([], npy.float_)
+ _offsets = np.array([], np.float_)
 _transOffset = transforms.IdentityTransform()
 _transforms = []
 
@@ -84,11 +84,11 @@
 self.set_antialiased(antialiaseds)
 
 self._uniform_offsets = None
- self._offsets = npy.array([], npy.float_)
+ self._offsets = np.array([], np.float_)
 if offsets is not None:
- offsets = npy.asarray(offsets, npy.float_)
+ offsets = np.asarray(offsets, np.float_)
 if len(offsets.shape) == 1:
- offsets = offsets[npy.newaxis,:] # Make it Nx2.
+ offsets = offsets[np.newaxis,:] # Make it Nx2.
 if transOffset is not None:
 Affine2D = transforms.Affine2D
 self._offsets = offsets
@@ -137,7 +137,7 @@
 if not transOffset.is_affine:
 offsets = transOffset.transform_non_affine(offsets)
 transOffset = transOffset.get_affine()
- offsets = npy.asarray(offsets, npy.float_)
+ offsets = np.asarray(offsets, np.float_)
 
 result = mpath.get_path_collection_extents(
 transform.frozen(), paths, self.get_transforms(),
@@ -166,7 +166,7 @@
 ys = self.convert_yunits(self._offsets[:1])
 offsets = zip(xs, ys)
 
- offsets = npy.asarray(offsets, npy.float_)
+ offsets = np.asarray(offsets, np.float_)
 
 self.update_scalarmappable()
 
@@ -206,7 +206,7 @@
 ind = mpath.point_in_path_collection(
 mouseevent.x, mouseevent.y, self._pickradius,
 transform.frozen(), paths, self.get_transforms(),
- npy.asarray(self._offsets, npy.float_),
+ np.asarray(self._offsets, np.float_),
 self._transOffset.frozen(), len(self._facecolors))
 return len(ind)>0,dict(ind=ind)
 
@@ -424,7 +424,7 @@
 
 # By converting to floats now, we can avoid that on every draw.
 self._coordinates = self._coordinates.reshape((meshHeight + 1, meshWidth + 1, 2))
- self._coordinates = npy.array(self._coordinates, npy.float_)
+ self._coordinates = np.array(self._coordinates, np.float_)
 
 def get_paths(self, dataTrans=None):
 if self._paths is None:
@@ -439,11 +439,11 @@
 c = coordinates
 # We could let the Path constructor generate the codes for us,
 # but this is faster, since we know they'll always be the same
- codes = npy.array(
+ codes = np.array(
 [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY],
 Path.code_type)
 
- points = npy.concatenate((
+ points = np.concatenate((
 c[0:-1, 0:-1],
 c[0:-1, 1: ],
 c[1: , 1: ],
@@ -470,7 +470,7 @@
 ys = self.convert_yunits(self._offsets[:1])
 offsets = zip(xs, ys)
 
- offsets = npy.asarray(offsets, npy.float_)
+ offsets = np.asarray(offsets, np.float_)
 
 if self.check_update('array'):
 self.update_scalarmappable()
@@ -556,8 +556,8 @@
 
 Example: see examples/dynamic_collection.py for complete example
 
- offsets = npy.random.rand(20,2)
- facecolors = [cm.jet(x) for x in npy.random.rand(20)]
+ offsets = np.random.rand(20,2)
+ facecolors = [cm.jet(x) for x in np.random.rand(20)]
 black = (0,0,0,1)
 
 collection = RegularPolyCollection(
@@ -584,7 +584,7 @@
 # in points^2
 self._transforms = [
 transforms.Affine2D().rotate(-self._rotation).scale(
- (npy.sqrt(x) * renderer.dpi / 72.0) / npy.sqrt(npy.pi))
+ (np.sqrt(x) * renderer.dpi / 72.0) / np.sqrt(np.pi))
 for x in self._sizes]
 return Collection.draw(self, renderer)
 
@@ -679,7 +679,7 @@
 pickradius=pickradius,
 **kwargs)
 
- self._facecolors = npy.array([])
+ self._facecolors = np.array([])
 self.set_segments(segments)
 
 def get_paths(self):
@@ -687,7 +687,7 @@
 
 def set_segments(self, segments):
 if segments is None: return
- segments = [npy.asarray(seg, npy.float_) for seg in segments]
+ segments = [np.asarray(seg, np.float_) for seg in segments]
 if self._uniform_offsets is not None:
 segments = self._add_offsets(segments)
 self._paths = [mpath.Path(seg) for seg in segments]
Modified: trunk/matplotlib/lib/matplotlib/colorbar.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colorbar.py	2008年04月29日 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/colorbar.py	2008年04月29日 15:14:36 UTC (rev 5098)
@@ -15,7 +15,7 @@
 
 '''
 
-import numpy as npy
+import numpy as np
 import matplotlib as mpl
 import matplotlib.colors as colors
 import matplotlib.cm as cm
@@ -185,7 +185,7 @@
 self._process_values()
 self._find_range()
 X, Y = self._mesh()
- C = self._values[:,npy.newaxis]
+ C = self._values[:,np.newaxis]
 self._config_axes(X, Y)
 if self.filled:
 self._add_solids(X, Y, C)
@@ -248,13 +248,13 @@
 '''
 N = X.shape[0]
 ii = [0, 1, N-2, N-1, 2*N-1, 2*N-2, N+1, N, 0]
- x = npy.take(npy.ravel(npy.transpose(X)), ii)
- y = npy.take(npy.ravel(npy.transpose(Y)), ii)
+ x = np.take(np.ravel(np.transpose(X)), ii)
+ y = np.take(np.ravel(np.transpose(Y)), ii)
 x = x.reshape((len(x), 1))
 y = y.reshape((len(y), 1))
 if self.orientation == 'horizontal':
- return npy.hstack((y, x))
- return npy.hstack((x, y))
+ return np.hstack((y, x))
+ return np.hstack((x, y))
 
 def _edges(self, X, Y):
 '''
@@ -276,7 +276,7 @@
 if self.orientation == 'vertical':
 args = (X, Y, C)
 else:
- args = (npy.transpose(Y), npy.transpose(X), npy.transpose(C))
+ args = (np.transpose(Y), np.transpose(X), np.transpose(C))
 kw = {'cmap':self.cmap, 'norm':self.norm,
 'shading':'flat', 'alpha':self.alpha}
 # Save, set, and restore hold state to keep pcolor from
@@ -303,8 +303,8 @@
 dummy, y = self._locate(levels)
 if len(y) <> N:
 raise ValueError("levels are outside colorbar range")
- x = npy.array([0.0, 1.0])
- X, Y = npy.meshgrid(x,y)
+ x = np.array([0.0, 1.0])
+ X, Y = np.meshgrid(x,y)
 if self.orientation == 'vertical':
 xy = [zip(X[i], Y[i]) for i in range(N)]
 else:
@@ -348,7 +348,7 @@
 locator.set_data_interval(*intv)
 formatter.set_view_interval(*intv)
 formatter.set_data_interval(*intv)
- b = npy.array(locator())
+ b = np.array(locator())
 b, ticks = self._locate(b)
 formatter.set_locs(b)
 ticklabels = [formatter(t, i) for i, t in enumerate(b)]
@@ -364,32 +364,32 @@
 if b is None:
 b = self.boundaries
 if b is not None:
- self._boundaries = npy.asarray(b, dtype=float)
+ self._boundaries = np.asarray(b, dtype=float)
 if self.values is None:
 self._values = 0.5*(self._boundaries[:-1]
 + self._boundaries[1:])
 if isinstance(self.norm, colors.NoNorm):
- self._values = (self._values + 0.00001).astype(npy.int16)
+ self._values = (self._values + 0.00001).astype(np.int16)
 return
- self._values = npy.array(self.values)
+ self._values = np.array(self.values)
 return
 if self.values is not None:
- self._values = npy.array(self.values)
+ self._values = np.array(self.values)
 if self.boundaries is None:
- b = npy.zeros(len(self.values)+1, 'd')
+ b = np.zeros(len(self.values)+1, 'd')
 b[1:-1] = 0.5*(self._values[:-1] - self._values[1:])
 b[0] = 2.0*b[1] - b[2]
 b[-1] = 2.0*b[-2] - b[-3]
 self._boundaries = b
 return
- self._boundaries = npy.array(self.boundaries)
+ self._boundaries = np.array(self.boundaries)
 return
 # Neither boundaries nor values are specified;
 # make reasonable ones based on cmap and norm.
 if isinstance(self.norm, colors.NoNorm):
 b = self._uniform_y(self.cmap.N+1) * self.cmap.N - 0.5
- v = npy.zeros((len(b)-1,), dtype=npy.int16)
- v[self._inside] = npy.arange(self.cmap.N, dtype=npy.int16)
+ v = np.zeros((len(b)-1,), dtype=np.int16)
+ v[self._inside] = np.arange(self.cmap.N, dtype=np.int16)
 if self.extend in ('both', 'min'):
 v[0] = -1
 if self.extend in ('both', 'max'):
@@ -403,8 +403,8 @@
 b = [b[0]-1] + b
 if self.extend in ('both', 'max'):
 b = b + [b[-1] + 1]
- b = npy.array(b)
- v = npy.zeros((len(b)-1,), dtype=float)
+ b = np.array(b)
+ v = np.zeros((len(b)-1,), dtype=float)
 bi = self.norm.boundaries
 v[self._inside] = 0.5*(bi[:-1] + bi[1:])
 if self.extend in ('both', 'min'):
@@ -461,19 +461,19 @@
 spaced boundaries, plus ends if required.
 '''
 if self.extend == 'neither':
- y = npy.linspace(0, 1, N)
+ y = np.linspace(0, 1, N)
 else:
 if self.extend == 'both':
- y = npy.zeros(N + 2, 'd')
+ y = np.zeros(N + 2, 'd')
 y[0] = -0.05
 y[-1] = 1.05
 elif self.extend == 'min':
- y = npy.zeros(N + 1, 'd')
+ y = np.zeros(N + 1, 'd')
 y[0] = -0.05
 else:
- y = npy.zeros(N + 1, 'd')
+ y = np.zeros(N + 1, 'd')
 y[-1] = 1.05
- y[self._inside] = npy.linspace(0, 1, N)
+ y[self._inside] = np.linspace(0, 1, N)
 return y
 
 def _proportional_y(self):
@@ -503,13 +503,13 @@
 transposition for a horizontal colorbar are done outside
 this function.
 '''
- x = npy.array([0.0, 1.0])
+ x = np.array([0.0, 1.0])
 if self.spacing == 'uniform':
 y = self._uniform_y(self._central_N())
 else:
 y = self._proportional_y()
 self._y = y
- X, Y = npy.meshgrid(x,y)
+ X, Y = np.meshgrid(x,y)
 if self.extend in ('min', 'both'):
 X[0,:] = 0.5
 if self.extend in ('max', 'both'):
@@ -535,19 +535,19 @@
 # floating point errors.
 xn = self.norm(x, clip=False).filled()
 in_cond = (xn > -0.001) & (xn < 1.001)
- xn = npy.compress(in_cond, xn)
- xout = npy.compress(in_cond, x)
+ xn = np.compress(in_cond, xn)
+ xout = np.compress(in_cond, x)
 # The rest is linear interpolation with clipping.
 y = self._y
 N = len(b)
- ii = npy.minimum(npy.searchsorted(b, xn), N-1)
- i0 = npy.maximum(ii - 1, 0)
+ ii = np.minimum(np.searchsorted(b, xn), N-1)
+ i0 = np.maximum(ii - 1, 0)
 #db = b[ii] - b[i0]
- db = npy.take(b, ii) - npy.take(b, i0)
- db = npy.where(i0==ii, 1.0, db)
+ db = np.take(b, ii) - np.take(b, i0)
+ db = np.where(i0==ii, 1.0, db)
 #dy = y[ii] - y[i0]
- dy = npy.take(y, ii) - npy.take(y, i0)
- z = npy.take(y, i0) + (xn-npy.take(b,i0))*dy/db
+ dy = np.take(y, ii) - np.take(y, i0)
+ z = np.take(y, i0) + (xn-np.take(b,i0))*dy/db
 return xout, z
 
 def set_alpha(self, alpha):
Modified: trunk/matplotlib/lib/matplotlib/colors.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colors.py	2008年04月29日 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/colors.py	2008年04月29日 15:14:36 UTC (rev 5098)
@@ -34,7 +34,7 @@
 'chartreuse' are supported.
 """
 import re
-import numpy as npy
+import numpy as np
 from numpy import ma
 import matplotlib.cbook as cbook
 
@@ -320,23 +320,23 @@
 """
 try:
 if c.lower() == 'none':
- return npy.zeros((0,4), dtype=npy.float_)
+ return np.zeros((0,4), dtype=np.float_)
 except AttributeError:
 pass
 if len(c) == 0:
- return npy.zeros((0,4), dtype=npy.float_)
+ return np.zeros((0,4), dtype=np.float_)
 try:
 result = [self.to_rgba(c, alpha)]
 except ValueError:
 # If c is a list it must be maintained as the same list
 # with modified items so that items can be appended to
 # it. This is needed for examples/dynamic_collections.py.
- if not isinstance(c, (list, npy.ndarray)): # specific; don't need duck-typing
+ if not isinstance(c, (list, np.ndarray)): # specific; don't need duck-typing
 c = list(c)
 for i, cc in enumerate(c):
 c[i] = self.to_rgba(cc, alpha) # change in place
 result = c
- return npy.asarray(result, npy.float_)
+ return np.asarray(result, np.float_)
 
 colorConverter = ColorConverter()
 
@@ -358,7 +358,7 @@
 gives the closest value for values of x between 0 and 1.
 """
 try:
- adata = npy.array(data)
+ adata = np.array(data)
 except:
 raise TypeError("data must be convertable to an array")
 shape = adata.shape
@@ -372,21 +372,21 @@
 if x[0] != 0. or x[-1] != 1.0:
 raise ValueError(
 "data mapping points must start with x=0. and end with x=1")
- if npy.sometrue(npy.sort(x)-x):
+ if np.sometrue(np.sort(x)-x):
 raise ValueError(
 "data mapping points must have x in increasing order")
 # begin generation of lookup table
 x = x * (N-1)
- lut = npy.zeros((N,), npy.float)
- xind = npy.arange(float(N))
- ind = npy.searchsorted(x, xind)[1:-1]
+ lut = np.zeros((N,), np.float)
+ xind = np.arange(float(N))
+ ind = np.searchsorted(x, xind)[1:-1]
 
 lut[1:-1] = ( ((xind[1:-1] - x[ind-1]) / (x[ind] - x[ind-1]))
 * (y0[ind] - y1[ind-1]) + y1[ind-1])
 lut[0] = y1[0]
 lut[-1] = y0[-1]
 # ensure that the lut is confined to values between 0 and 1 by clipping it
- npy.clip(lut, 0.0, 1.0)
+ np.clip(lut, 0.0, 1.0)
 #lut = where(lut > 1., 1., lut)
 #lut = where(lut < 0., 0., lut)
 return lut
@@ -437,26 +437,26 @@
 mask_bad = None
 if not cbook.iterable(X):
 vtype = 'scalar'
- xa = npy.array([X])
+ xa = np.array([X])
 else:
 vtype = 'array'
 xma = ma.asarray(X)
 xa = xma.filled(0)
 mask_bad = ma.getmask(xma)
- if xa.dtype.char in npy.typecodes['Float']:
- npy.putmask(xa, xa==1.0, 0.9999999) #Treat 1.0 as slightly less than 1.
+ if xa.dtype.char in np.typecodes['Float']:
+ np.putmask(xa, xa==1.0, 0.9999999) #Treat 1.0 as slightly less than 1.
 xa = (xa * self.N).astype(int)
 # Set the over-range indices before the under-range;
 # otherwise the under-range values get converted to over-range.
- npy.putmask(xa, xa>self.N-1, self._i_over)
- npy.putmask(xa, xa<0, self._i_under)
+ np.putmask(xa, xa>self.N-1, self._i_over)
+ np.putmask(xa, xa<0, self._i_under)
 if mask_bad is not None and mask_bad.shape == xa.shape:
- npy.putmask(xa, mask_bad, self._i_bad)
+ np.putmask(xa, mask_bad, self._i_bad)
 if bytes:
- lut = (self._lut * 255).astype(npy.uint8)
+ lut = (self._lut * 255).astype(np.uint8)
 else:
 lut = self._lut
- rgba = npy.empty(shape=xa.shape+(4,), dtype=lut.dtype)
+ rgba = np.empty(shape=xa.shape+(4,), dtype=lut.dtype)
 lut.take(xa, axis=0, mode='clip', out=rgba)
 # twice as fast as lut[xa];
 # using the clip or wrap mode and providing an
@@ -501,8 +501,8 @@
 raise NotImplementedError("Abstract class only")
 
 def is_gray(self):
- return (npy.alltrue(self._lut[:,0] == self._lut[:,1])
- and npy.alltrue(self._lut[:,0] == self._lut[:,2]))
+ return (np.alltrue(self._lut[:,0] == self._lut[:,1])
+ and np.alltrue(self._lut[:,0] == self._lut[:,2]))
 
 
 class LinearSegmentedColormap(Colormap):
@@ -527,7 +527,7 @@
 self._segmentdata = segmentdata
 
 def _init(self):
- self._lut = npy.ones((self.N + 3, 4), npy.float)
+ self._lut = np.ones((self.N + 3, 4), np.float)
 self._lut[:-3, 0] = makeMappingArray(self.N, self._segmentdata['red'])
 self._lut[:-3, 1] = makeMappingArray(self.N, self._segmentdata['green'])
 self._lut[:-3, 2] = makeMappingArray(self.N, self._segmentdata['blue'])
@@ -579,9 +579,9 @@
 
 
 def _init(self):
- rgb = npy.array([colorConverter.to_rgb(c)
- for c in self.colors], npy.float)
- self._lut = npy.zeros((self.N + 3, 4), npy.float)
+ rgb = np.array([colorConverter.to_rgb(c)
+ for c in self.colors], np.float)
+ self._lut = np.zeros((self.N + 3, 4), np.float)
 self._lut[:-3, :-1] = rgb
 self._lut[:-3, -1] = 1
 self._isinit = True
@@ -615,10 +615,10 @@
 
 if cbook.iterable(value):
 vtype = 'array'
- val = ma.asarray(value).astype(npy.float)
+ val = ma.asarray(value).astype(np.float)
 else:
 vtype = 'scalar'
- val = ma.array([value]).astype(npy.float)
+ val = ma.array([value]).astype(np.float)
 
 self.autoscale_None(val)
 vmin, vmax = self.vmin, self.vmax
@@ -629,7 +629,7 @@
 else:
 if clip:
 mask = ma.getmask(val)
- val = ma.array(npy.clip(val.filled(vmax), vmin, vmax),
+ val = ma.array(np.clip(val.filled(vmax), vmin, vmax),
 mask=mask)
 result = (val-vmin) * (1.0/(vmax-vmin))
 if vtype == 'scalar':
@@ -674,10 +674,10 @@
 
 if cbook.iterable(value):
 vtype = 'array'
- val = ma.asarray(value).astype(npy.float)
+ val = ma.asarray(value).astype(np.float)
 else:
 vtype = 'scalar'
- val = ma.array([value]).astype(npy.float)
+ val = ma.array([value]).astype(np.float)
 
 self.autoscale_None(val)
 vmin, vmax = self.vmin, self.vmax
@@ -690,9 +690,9 @@
 else:
 if clip:
 mask = ma.getmask(val)
- val = ma.array(npy.clip(val.filled(vmax), vmin, vmax),
+ val = ma.array(np.clip(val.filled(vmax), vmin, vmax),
 mask=mask)
- result = (ma.log(val)-npy.log(vmin))/(npy.log(vmax)-npy.log(vmin))
+ result = (ma.log(val)-np.log(vmin))/(np.log(vmax)-np.log(vmin))
 if vtype == 'scalar':
 result = result[0]
 return result
@@ -737,7 +737,7 @@
 self.clip = clip
 self.vmin = boundari...
 
[truncated message content]
From: <md...@us...> - 2008年04月29日 14:24:06
Revision: 5097
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5097&view=rev
Author: mdboom
Date: 2008年04月29日 07:22:48 -0700 (2008年4月29日)
Log Message:
-----------
Check the return value of fwrite (and eliminate gcc 4.x warnings)
Modified Paths:
--------------
 trunk/matplotlib/src/_backend_agg.cpp
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp	2008年04月29日 13:35:47 UTC (rev 5096)
+++ trunk/matplotlib/src/_backend_agg.cpp	2008年04月29日 14:22:48 UTC (rev 5097)
@@ -1300,12 +1300,16 @@
 const char *file_name = fileName.c_str();
 if ((fp = fopen(file_name, "wb")) == NULL)
 throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() );
- fwrite(pixBuffer, 1, NUMBYTES, fp);
+ if (fwrite(pixBuffer, 1, NUMBYTES, fp) != NUMBYTES) {
+ fclose(fp);
+ throw Py::RuntimeError( Printf("Error writing to file %s", file_name).str() );
+ }
 close_file = true;
- fclose(fp);
 } else if (PyFile_CheckExact(py_fileobj.ptr())) {
 fp = PyFile_AsFile(py_fileobj.ptr());
- fwrite(pixBuffer, 1, NUMBYTES, fp);
+ if (fwrite(pixBuffer, 1, NUMBYTES, fp) != NUMBYTES) {
+ throw Py::RuntimeError( "Error writing to file" );
+ }
 } else {
 PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write");
 if (!(write_method && PyCallable_Check(write_method))) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <mme...@us...> - 2008年04月29日 13:35:52
Revision: 5096
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5096&view=rev
Author: mmetz_bn
Date: 2008年04月29日 06:35:47 -0700 (2008年4月29日)
Log Message:
-----------
fixed bug in mlab.sqrtm; numpy.linalg.eig behaves different than Numeric did
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/lib/matplotlib/mlab.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2008年04月29日 13:21:48 UTC (rev 5095)
+++ trunk/matplotlib/CHANGELOG	2008年04月29日 13:35:47 UTC (rev 5096)
@@ -1,3 +1,5 @@
+2008年04月29日 Fix bug in mlab.sqrtm - MM
+
 2008年04月28日 Fix bug in SVG text with Mozilla-based viewers (the symbol
 tag is not supported) - MGD
 
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py	2008年04月29日 13:21:48 UTC (rev 5095)
+++ trunk/matplotlib/lib/matplotlib/mlab.py	2008年04月29日 13:35:47 UTC (rev 5096)
@@ -1901,7 +1901,7 @@
 def sqrtm(x):
 """
 Returns the square root of a square matrix.
- This means that s=sqrtm(x) implies s*s = x.
+ This means that s=sqrtm(x) implies dot(s,s) = x.
 Note that s and x are matrices.
 """
 return mfuncC(npy.sqrt, x)
@@ -1914,9 +1914,10 @@
 """
 
 x = npy.asarray(x)
- (v, u) = npy.linalg.eig(x)
- uT = u.transpose()
+ (v,uT) = npy.linalg.eig(x)
 V = npy.diag(f(v+0j))
+ # todo: warning: this is not exactly what matlab does
+ # MATLAB "B/A is roughly the same as B*inv(A)"
 y = npy.dot(uT, npy.dot(V, npy.linalg.inv(uT)))
 return approx_real(y)
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <mme...@us...> - 2008年04月29日 13:22:29
Revision: 5095
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5095&view=rev
Author: mmetz_bn
Date: 2008年04月29日 06:21:48 -0700 (2008年4月29日)
Log Message:
-----------
fixed bug in mlab.sqrtm; numpy.linalg.eig behaves different than Numeric did
Modified Paths:
--------------
 branches/v0_91_maint/CHANGELOG
 branches/v0_91_maint/lib/matplotlib/mlab.py
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG	2008年04月28日 19:17:31 UTC (rev 5094)
+++ branches/v0_91_maint/CHANGELOG	2008年04月29日 13:21:48 UTC (rev 5095)
@@ -1,3 +1,5 @@
+2008年04月29日 Fix bug in mlab.sqrtm - MM
+
 2008年04月28日 Fix bug in SVG text with Mozilla-based viewers (the symbol
 tag is not supported) - MGD
 
Modified: branches/v0_91_maint/lib/matplotlib/mlab.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/mlab.py	2008年04月28日 19:17:31 UTC (rev 5094)
+++ branches/v0_91_maint/lib/matplotlib/mlab.py	2008年04月29日 13:21:48 UTC (rev 5095)
@@ -1901,7 +1901,7 @@
 def sqrtm(x):
 """
 Returns the square root of a square matrix.
- This means that s=sqrtm(x) implies s*s = x.
+ This means that s=sqrtm(x) implies dot(s,s) = x.
 Note that s and x are matrices.
 """
 return mfuncC(npy.sqrt, x)
@@ -1914,9 +1914,10 @@
 """
 
 x = npy.asarray(x)
- (v, u) = npy.linalg.eig(x)
- uT = u.transpose()
+ (v,uT) = npy.linalg.eig(x)
 V = npy.diag(f(v+0j))
+ # todo: warning: this is not exactly what matlab does
+ # MATLAB "B/A is roughly the same as B*inv(A)"
 y = npy.dot(uT, npy.dot(V, npy.linalg.inv(uT)))
 return approx_real(y)
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <mme...@us...> - 2008年04月28日 19:19:52
Revision: 5094
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5094&view=rev
Author: mmetz_bn
Date: 2008年04月28日 12:17:31 -0700 (2008年4月28日)
Log Message:
-----------
npy usage
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2008年04月28日 18:26:08 UTC (rev 5093)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2008年04月28日 19:17:31 UTC (rev 5094)
@@ -4519,14 +4519,13 @@
 x = npy.log10(x)
 if yscale=='log':
 y = npy.log10(y)
- xmin = min(x)
- xmax = max(x)
- ymin = min(y)
- ymax = max(y)
+ xmin = npy.amin(x)
+ xmax = npy.amax(x)
+ ymin = npy.amin(y)
+ ymax = npy.amax(y)
 # In the x-direction, the hexagons exactly cover the region from
 # xmin to xmax. Need some padding to avoid roundoff errors.
- width = xmax - xmin
- padding = 1.e-9 * width
+ padding = 1.e-9 * (xmax - xmin)
 xmin -= padding
 xmax += padding
 sx = (xmax-xmin) / nx
@@ -4551,21 +4550,22 @@
 
 d1 = (x-ix1)**2 + 3.0 * (y-iy1)**2
 d2 = (x-ix2-0.5)**2 + 3.0 * (y-iy2-0.5)**2
+ bdist = (d1<d2)
 
 for i in xrange(len(x)):
- if d1[i] < d2[i]:
+ if bdist[i]:
 lattice1[ix1[i], iy1[i]]+=1
 else:
 lattice2[ix2[i], iy2[i]]+=1
 
 px = xmin + sx * npy.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0])
- py = ymin + sy * npy.array([-0.5, 0.5 ,1.0, 0.5, -0.5, -1.0]) / 3.0
+ py = ymin + sy * npy.array([-0.5, 0.5, 1.0, 0.5, -0.5, -1.0]) / 3.0
 
 polygons = npy.zeros((6, n, 2), float)
 polygons[:,:nx1*ny1,0] = npy.repeat(npy.arange(nx1), ny1)
- polygons[:,:nx1*ny1,1] = npy.array(range(ny1) * nx1)
+ polygons[:,:nx1*ny1,1] = npy.tile(npy.arange(ny1), nx1)
 polygons[:,nx1*ny1:,0] = npy.repeat(npy.arange(nx2) + 0.5, ny2)
- polygons[:,nx1*ny1:,1] = npy.array(range(ny2) * nx2) + 0.5
+ polygons[:,nx1*ny1:,1] = npy.tile(npy.arange(ny2), nx2) + 0.5
 
 polygons = npy.transpose(polygons, axes=[1,0,2])
 polygons[:,:,0] *= sx
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2008年04月28日 18:27:25
Revision: 5093
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5093&view=rev
Author: efiring
Date: 2008年04月28日 11:26:08 -0700 (2008年4月28日)
Log Message:
-----------
Add hexbin_demo, and use log10 for log in hexbin
Modified Paths:
--------------
 trunk/matplotlib/examples/backend_driver.py
 trunk/matplotlib/lib/matplotlib/axes.py
Added Paths:
-----------
 trunk/matplotlib/examples/hexbin_demo.py
Modified: trunk/matplotlib/examples/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/backend_driver.py	2008年04月28日 16:52:44 UTC (rev 5092)
+++ trunk/matplotlib/examples/backend_driver.py	2008年04月28日 18:26:08 UTC (rev 5093)
@@ -49,6 +49,7 @@
 'fill_demo.py',
 'finance_demo.py',
 'fonts_demo_kw.py',
+ 'hexbin_demo.py',
 'histogram_demo.py',
 'hline_demo.py',
 'image_demo.py',
Added: trunk/matplotlib/examples/hexbin_demo.py
===================================================================
--- trunk/matplotlib/examples/hexbin_demo.py	 (rev 0)
+++ trunk/matplotlib/examples/hexbin_demo.py	2008年04月28日 18:26:08 UTC (rev 5093)
@@ -0,0 +1,34 @@
+'''
+hexbin is an axes method or pyplot function that is essentially
+a pcolor of a 2-D histogram with hexagonal cells. It can be
+much more informative than a scatter plot; in the first subplot
+below, try substituting 'scatter' for 'hexbin'.
+'''
+
+from matplotlib.pyplot import *
+import numpy as np
+
+n = 100000
+x = np.random.standard_normal(n)
+y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)
+xmin = x.min()
+xmax = x.max()
+ymin = y.min()
+ymax = y.max()
+
+subplot(121)
+hexbin(x,y)
+axis([xmin, xmax, ymin, ymax])
+title("Hexagon binning")
+cb = colorbar()
+cb.set_label('counts')
+
+subplot(122)
+hexbin(x,y,bins='log')
+axis([xmin, xmax, ymin, ymax])
+title("With a log color scale")
+cb = colorbar()
+cb.set_label('log10(N)')
+
+show()
+
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2008年04月28日 16:52:44 UTC (rev 5092)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2008年04月28日 18:26:08 UTC (rev 5093)
@@ -4447,7 +4447,7 @@
 each hexagon directly corresponds to its count
 value.
 bins='log' : Use a logarithmic scale for the color map.
- Internally, log(count+1) is used to determine
+ Internally, log10(count+1) is used to determine
 the hexagon color.
 bins=<integer> : Divide the counts in the specified number of
 bins, and color the hexagons accordingly
@@ -4456,10 +4456,10 @@
 to be used.
 
 * xscale = 'linear' | 'log':
- Use a logarithmic scale on the horizontal axis.
+ Use a log10 scale on the horizontal axis.
 
 * yscale = 'linear' | 'log':
- Use a logarithmic scale on the vertical axis.
+ Use a log10 scale on the vertical axis.
 
 Other keyword args; the color mapping and normalization arguments.
 
@@ -4516,9 +4516,9 @@
 x = npy.array(x, float)
 y = npy.array(y, float)
 if xscale=='log':
- x = npy.log(x)
+ x = npy.log10(x)
 if yscale=='log':
- y = npy.log(y)
+ y = npy.log10(y)
 xmin = min(x)
 xmax = max(x)
 ymin = min(y)
@@ -4574,14 +4574,14 @@
 polygons[:,:,1] += py
 
 if xscale=='log':
- polygons[:,:,0] = npy.exp(polygons[:,:,0])
- xmin = math.exp(xmin)
- xmax = math.exp(xmax)
+ polygons[:,:,0] = 10**(polygons[:,:,0])
+ xmin = 10**xmin
+ xmax = 10**xmax
 self.set_xscale('log')
 if yscale=='log':
- polygons[:,:,1] = npy.exp(polygons[:,:,1])
- ymin = math.exp(ymin)
- ymax = math.exp(ymax)
+ polygons[:,:,1] = 10**(polygons[:,:,1])
+ ymin = 10**ymin
+ ymax = 10**ymax
 self.set_yscale('log')
 
 class HexagonBinCollection(mcoll.PolyCollection):
@@ -4607,7 +4607,7 @@
 
 # Transform the counts if needed
 if bins=='log':
- counts = npy.log(counts+1)
+ counts = npy.log10(counts+1)
 elif bins!=None:
 if not iterable(bins):
 minimum, maximum = min(counts), max(counts)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年04月28日 17:16:02
Revision: 5092
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5092&view=rev
Author: mdboom
Date: 2008年04月28日 09:52:44 -0700 (2008年4月28日)
Log Message:
-----------
Removing SVN conflict marker.
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2008年04月28日 14:19:06 UTC (rev 5091)
+++ trunk/matplotlib/CHANGELOG	2008年04月28日 16:52:44 UTC (rev 5092)
@@ -14,7 +14,6 @@
 2008年04月24日 Fix compilation issues on VS2003 (Thanks Martin Spacek for
 all the help) - MGD
 
->>>>>>> .merge-right.r5090
 2008年04月24日 Fix sub/superscripts when the size of the font has been
 changed - MGD
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年04月28日 14:19:25
Revision: 5091
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5091&view=rev
Author: mdboom
Date: 2008年04月28日 07:19:06 -0700 (2008年4月28日)
Log Message:
-----------
Merged revisions 5069-5090 via svnmerge from 
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint
........
 r5088 | mdboom | 2008年04月28日 09:07:41 -0400 (2008年4月28日) | 2 lines
 
 Fix SVG text rendering bug affecting Mozilla-based viewers.
........
 r5089 | mdboom | 2008年04月28日 09:41:28 -0400 (2008年4月28日) | 3 lines
 
 Fix bug where fraction beams were too wide at lower dpi's. Fix
 sub/superscript placement at different dpi's.
........
 r5090 | mdboom | 2008年04月28日 09:49:50 -0400 (2008年4月28日) | 2 lines
 
 Oops in last commit -- left in debugging info.
........
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
 trunk/matplotlib/lib/matplotlib/mathtext.py
Property Changed:
----------------
 trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
 - /branches/v0_91_maint:1-5068
 + /branches/v0_91_maint:1-5090
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2008年04月28日 13:49:50 UTC (rev 5090)
+++ trunk/matplotlib/CHANGELOG	2008年04月28日 14:19:06 UTC (rev 5091)
@@ -1,3 +1,6 @@
+2008年04月28日 Fix bug in SVG text with Mozilla-based viewers (the symbol
+ tag is not supported) - MGD
+
 2008年04月27日 Applied patch by Michiel de Hoon to add hexbin
 axes method and pyplot function - EF
 
@@ -11,6 +14,7 @@
 2008年04月24日 Fix compilation issues on VS2003 (Thanks Martin Spacek for
 all the help) - MGD
 
+>>>>>>> .merge-right.r5090
 2008年04月24日 Fix sub/superscripts when the size of the font has been
 changed - MGD
 
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py	2008年04月28日 13:49:50 UTC (rev 5090)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py	2008年04月28日 14:19:06 UTC (rev 5091)
@@ -401,7 +401,7 @@
 currx, curry = step[-2], -step[-1]
 path_data = ''.join(path_data)
 char_num = 'c_%s' % md5.new(path_data).hexdigest()
- path_element = '<symbol id="%s"><path d="%s"/></symbol>\n' % (char_num, ''.join(path_data))
+ path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
 self._char_defs[char_id] = char_num
 return path_element
 
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2008年04月28日 13:49:50 UTC (rev 5090)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2008年04月28日 14:19:06 UTC (rev 5091)
@@ -651,12 +651,12 @@
 # Some fonts don't store the xHeight, so we do a poor man's xHeight
 metrics = self.get_metrics(font, 'it', 'x', fontsize, dpi)
 return metrics.iceberg
- xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0)
+ xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0) * (dpi / 100.0)
 return xHeight
 
 def get_underline_thickness(self, font, fontsize, dpi):
 cached_font = self._get_font(font)
- return max(1.0, cached_font.font.underline_thickness / 64.0 / fontsize * 10.0)
+ return cached_font.font.underline_thickness / 64.0 / fontsize * (10.0 * dpi / 100.0)
 
 def get_kern(self, font1, fontclass1, sym1, fontsize1,
 font2, fontclass2, sym2, fontsize2, dpi):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5090
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5090&view=rev
Author: mdboom
Date: 2008年04月28日 06:49:50 -0700 (2008年4月28日)
Log Message:
-----------
Oops in last commit -- left in debugging info.
Modified Paths:
--------------
 branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年04月28日 13:41:28 UTC (rev 5089)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年04月28日 13:49:50 UTC (rev 5090)
@@ -390,7 +390,6 @@
 currx, curry = step[-2], -step[-1]
 path_data = ''.join(path_data)
 char_num = 'c_%s' % md5.new(path_data).hexdigest()
- char_num = len(self._char_defs)
 path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
 self._char_defs[char_id] = char_num
 return path_element
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5089
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5089&view=rev
Author: mdboom
Date: 2008年04月28日 06:41:28 -0700 (2008年4月28日)
Log Message:
-----------
Fix bug where fraction beams were too wide at lower dpi's. Fix
sub/superscript placement at different dpi's.
Modified Paths:
--------------
 branches/v0_91_maint/lib/matplotlib/mathtext.py
Modified: branches/v0_91_maint/lib/matplotlib/mathtext.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/mathtext.py	2008年04月28日 13:07:41 UTC (rev 5088)
+++ branches/v0_91_maint/lib/matplotlib/mathtext.py	2008年04月28日 13:41:28 UTC (rev 5089)
@@ -651,12 +651,12 @@
 # Some fonts don't store the xHeight, so we do a poor man's xHeight
 metrics = self.get_metrics(font, 'it', 'x', fontsize, dpi)
 return metrics.iceberg
- xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0)
+ xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0) * (dpi / 100.0)
 return xHeight
 
 def get_underline_thickness(self, font, fontsize, dpi):
 cached_font = self._get_font(font)
- return max(1.0, cached_font.font.underline_thickness / 64.0 / fontsize * 10.0)
+ return cached_font.font.underline_thickness / 64.0 / fontsize * (10.0 * dpi / 100.0)
 
 def get_kern(self, font1, fontclass1, sym1, fontsize1,
 font2, fontclass2, sym2, fontsize2, dpi):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年04月28日 13:08:42
Revision: 5088
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5088&view=rev
Author: mdboom
Date: 2008年04月28日 06:07:41 -0700 (2008年4月28日)
Log Message:
-----------
Fix SVG text rendering bug affecting Mozilla-based viewers.
Modified Paths:
--------------
 branches/v0_91_maint/CHANGELOG
 branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG	2008年04月28日 11:31:19 UTC (rev 5087)
+++ branches/v0_91_maint/CHANGELOG	2008年04月28日 13:07:41 UTC (rev 5088)
@@ -1,3 +1,6 @@
+2008年04月28日 Fix bug in SVG text with Mozilla-based viewers (the symbol
+ tag is not supported) - MGD
+
 2008年04月24日 Fix sub/superscripts when the size of the font has been
 changed - MGD
 
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年04月28日 11:31:19 UTC (rev 5087)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年04月28日 13:07:41 UTC (rev 5088)
@@ -390,7 +390,8 @@
 currx, curry = step[-2], -step[-1]
 path_data = ''.join(path_data)
 char_num = 'c_%s' % md5.new(path_data).hexdigest()
- path_element = '<symbol id="%s"><path d="%s"/></symbol>\n' % (char_num, ''.join(path_data))
+ char_num = len(self._char_defs)
+ path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
 self._char_defs[char_id] = char_num
 return path_element
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <mme...@us...> - 2008年04月28日 11:31:28
Revision: 5087
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5087&view=rev
Author: mmetz_bn
Date: 2008年04月28日 04:31:19 -0700 (2008年4月28日)
Log Message:
-----------
array of indices as integers in hexbin
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2008年04月28日 07:41:25 UTC (rev 5086)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2008年04月28日 11:31:19 UTC (rev 5087)
@@ -4533,10 +4533,10 @@
 sy = (ymax-ymin) / ny
 x = (x-xmin)/sx
 y = (y-ymin)/sy
- ix1 = npy.round(x)
- iy1 = npy.round(y)
- ix2 = npy.floor(x)
- iy2 = npy.floor(y)
+ ix1 = npy.round(x).astype(int)
+ iy1 = npy.round(y).astype(int)
+ ix2 = npy.floor(x).astype(int)
+ iy2 = npy.floor(y).astype(int)
 
 nx1 = nx + 1
 ny1 = ny + 1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2008年04月28日 07:42:59
Revision: 5086
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5086&view=rev
Author: efiring
Date: 2008年04月28日 00:41:25 -0700 (2008年4月28日)
Log Message:
-----------
Add hexbin to one more place in boilerplate.py
Modified Paths:
--------------
 trunk/matplotlib/boilerplate.py
Modified: trunk/matplotlib/boilerplate.py
===================================================================
--- trunk/matplotlib/boilerplate.py	2008年04月28日 07:36:37 UTC (rev 5085)
+++ trunk/matplotlib/boilerplate.py	2008年04月28日 07:41:25 UTC (rev 5086)
@@ -99,6 +99,7 @@
 cmappable = {
 'contour' : 'if ret._A is not None: gci._current = ret',
 'contourf': 'if ret._A is not None: gci._current = ret',
+ 'hexbin' : 'gci._current = ret',
 'scatter' : 'gci._current = ret',
 'pcolor' : 'gci._current = ret',
 'pcolormesh' : 'gci._current = ret',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2008年04月28日 07:36:49
Revision: 5085
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5085&view=rev
Author: efiring
Date: 2008年04月28日 00:36:37 -0700 (2008年4月28日)
Log Message:
-----------
removed dead code from end of colorbar.py
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/colorbar.py
Modified: trunk/matplotlib/lib/matplotlib/colorbar.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colorbar.py	2008年04月28日 07:24:33 UTC (rev 5084)
+++ trunk/matplotlib/lib/matplotlib/colorbar.py	2008年04月28日 07:36:37 UTC (rev 5085)
@@ -667,36 +667,3 @@
 ''' % make_axes_kw_doc
 
 
-'''
-The following does not work correctly. The problem seems to be that
-the transforms work right only when fig.add_axes(rect) is used to
-generate the axes, not when the axes object is generated first and
-then fig.add_axes(ax) is called. I don't understand this. - EF
-
-class ColorbarAxes(axes.Axes):
- def __init__(self, parent, **kw):
- orientation = kw.setdefault('orientation', 'vertical')
- fraction = kw.pop('fraction', 0.15)
- shrink = kw.pop('shrink', 1.0)
- aspect = kw.pop('aspect', 20)
- self.cbkw = kw
- pb = transforms.PBox(parent.get_position())
- if orientation == 'vertical':
- pb1, pbcb = pb.splitx(1.0-fraction)
- pbcb.shrink(1.0, shrink).anchor('C')
- anchor = (0.3, 0.5)
- panchor = (0.8, 0.5)
- else:
- pbcb, pb1 = pb.splity(fraction)
- pbcb.shrink(shrink, 1.0).anchor('C')
- aspect = 1.0/aspect
- anchor = (0.5, 0.2)
- panchor = (0.5, 0.8)
- parent.set_position(pb1)
- parent.set_anchor(panchor)
- fig = parent.get_figure()
- axes.Axes.__init__(self, fig, pbcb)
- fig.add_axes(self)
- self.set_aspect(aspect, anchor=anchor, adjustable='box')
-
-'''
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2008年04月28日 07:25:12
Revision: 5084
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5084&view=rev
Author: efiring
Date: 2008年04月28日 00:24:33 -0700 (2008年4月28日)
Log Message:
-----------
Added hexbin axes method and pyplot function by Michiel de Hoon.
Tracker 1952339.
Modified Paths:
--------------
 trunk/matplotlib/API_CHANGES
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/boilerplate.py
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/pyplot.py
Modified: trunk/matplotlib/API_CHANGES
===================================================================
--- trunk/matplotlib/API_CHANGES	2008年04月28日 01:59:05 UTC (rev 5083)
+++ trunk/matplotlib/API_CHANGES	2008年04月28日 07:24:33 UTC (rev 5084)
@@ -1,3 +1,7 @@
+ New axes method and pyplot function, hexbin, is an alternative
+ to scatter for large datasets. It makes something like a
+ pcolor of a 2-D histogram, but uses hexagonal bins.
+
 New kwarg, "symmetric", in MaxNLocator
 allows one require an axis to be centered on zero.
 
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2008年04月28日 01:59:05 UTC (rev 5083)
+++ trunk/matplotlib/CHANGELOG	2008年04月28日 07:24:33 UTC (rev 5084)
@@ -1,3 +1,6 @@
+2008年04月27日 Applied patch by Michiel de Hoon to add hexbin
+ axes method and pyplot function - EF
+
 2008年04月25日 Enforce python >= 2.4; remove subprocess build - EF
 
 2008年04月25日 Enforce the numpy requirement at build time - JDH
Modified: trunk/matplotlib/boilerplate.py
===================================================================
--- trunk/matplotlib/boilerplate.py	2008年04月28日 01:59:05 UTC (rev 5083)
+++ trunk/matplotlib/boilerplate.py	2008年04月28日 07:24:33 UTC (rev 5084)
@@ -63,6 +63,7 @@
 'csd',
 'errorbar',
 'fill',
+ 'hexbin',
 'hist',
 'hlines',
 'imshow',
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2008年04月28日 01:59:05 UTC (rev 5083)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2008年04月28日 07:24:33 UTC (rev 5084)
@@ -4417,6 +4417,229 @@
 
 scatter.__doc__ = cbook.dedent(scatter.__doc__) % martist.kwdocd
 
+ def hexbin(self, x, y, gridsize = 100, bins = None,
+ xscale = 'linear', yscale = 'linear',
+ cmap=None, norm=None, vmin=None, vmax=None,
+ alpha=1.0, linewidths=None, edgecolors='none',
+ **kwargs):
+ """
+ HEXBIN(x, y, gridsize = 100, bins = None,
+ xscale = 'linear', yscale = 'linear',
+ cmap=None, norm=None, vmin=None, vmax=None,
+ alpha=1.0, linewidths=None, edgecolors='none'
+ **kwargs)
+
+ Make a hexagonal binning plot of x versus y, where x, y are 1-D
+ sequences of the same length, N.
+
+ Either or both of x and y may be masked arrays, in which case all
+ masks will be combined and only unmasked points will be plotted.
+
+ * gridsize=100 : The number of hexagons in the x-direction. The
+ corresponding number of hexagons in the
+ y-direction is chosen such that the hexagons are
+ approximately regular.
+ Alternatively, gridsize can be a tuple with two
+ elements specifying the number of hexagons in
+ the x-direction and the y-direction.
+
+ * bins=None : If None, no binning is applied; the color of
+ each hexagon directly corresponds to its count
+ value.
+ bins='log' : Use a logarithmic scale for the color map.
+ Internally, log(count+1) is used to determine
+ the hexagon color.
+ bins=<integer> : Divide the counts in the specified number of
+ bins, and color the hexagons accordingly
+ bins=<a sequence of values> :
+ The values of the lower bound of the bins
+ to be used.
+
+ * xscale = 'linear' | 'log':
+ Use a logarithmic scale on the horizontal axis.
+
+ * yscale = 'linear' | 'log':
+ Use a logarithmic scale on the vertical axis.
+
+ Other keyword args; the color mapping and normalization arguments.
+
+ * cmap = cm.jet : a colors.Colormap instance from cm.
+ defaults to rc image.cmap
+
+ * norm = colors.Normalize() : colors.Normalize instance
+ is used to scale luminance data to 0,1.
+
+ * vmin=None and vmax=None : vmin and vmax are used in conjunction
+ with norm to normalize luminance data. If either are None, the
+ min and max of the color array C is used. Note if you pass a norm
+ instance, your settings for vmin and vmax will be ignored
+
+ * alpha =1.0 : the alpha value for the patches
+
+ * linewidths, if None, defaults to (lines.linewidth,). Note
+ that this is a tuple, and if you set the linewidths
+ argument you must set it as a sequence of floats, as
+ required by RegularPolyCollection -- see
+ collections.RegularPolyCollection for details
+
+ Optional kwargs control the Collection properties; in
+ particular:
+
+ edgecolors='none' : Draw the edges in the same color
+ as the fill color. This is the default, as
+ it avoids unsightly unpainted pixels
+ between the hexagons.
+ edgecolors=None : Draw the outlines in the default color.
+ edgecolors=<a matplotlib color arg or sequence of rgba tuples>
+ : Draw the outlines in the specified color.
+
+ Here are the standard descriptions of all the Collection kwargs:
+ %(Collection)s
+
+ The return value is a PolyCollection instance; use get_array() on
+ this PolyCollection to get the counts in each hexagon.
+ """
+
+ if not self._hold: self.cla()
+
+ self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
+
+ x, y = delete_masked_points(x, y)
+
+ # Set the size of the hexagon grid
+ if iterable(gridsize):
+ nx, ny = gridsize
+ else:
+ nx = gridsize
+ ny = int(nx/math.sqrt(3))
+ # Count the number of data in each hexagon
+ x = npy.array(x, float)
+ y = npy.array(y, float)
+ if xscale=='log':
+ x = npy.log(x)
+ if yscale=='log':
+ y = npy.log(y)
+ xmin = min(x)
+ xmax = max(x)
+ ymin = min(y)
+ ymax = max(y)
+ # In the x-direction, the hexagons exactly cover the region from
+ # xmin to xmax. Need some padding to avoid roundoff errors.
+ width = xmax - xmin
+ padding = 1.e-9 * width
+ xmin -= padding
+ xmax += padding
+ sx = (xmax-xmin) / nx
+ sy = (ymax-ymin) / ny
+ x = (x-xmin)/sx
+ y = (y-ymin)/sy
+ ix1 = npy.round(x)
+ iy1 = npy.round(y)
+ ix2 = npy.floor(x)
+ iy2 = npy.floor(y)
+
+ nx1 = nx + 1
+ ny1 = ny + 1
+ nx2 = nx
+ ny2 = ny
+ n = nx1*ny1+nx2*ny2
+ counts = npy.zeros(n)
+ lattice1 = counts[:nx1*ny1]
+ lattice2 = counts[nx1*ny1:]
+ lattice1.shape = (nx1,ny1)
+ lattice2.shape = (nx2,ny2)
+
+ d1 = (x-ix1)**2 + 3.0 * (y-iy1)**2
+ d2 = (x-ix2-0.5)**2 + 3.0 * (y-iy2-0.5)**2
+
+ for i in xrange(len(x)):
+ if d1[i] < d2[i]:
+ lattice1[ix1[i], iy1[i]]+=1
+ else:
+ lattice2[ix2[i], iy2[i]]+=1
+
+ px = xmin + sx * npy.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0])
+ py = ymin + sy * npy.array([-0.5, 0.5 ,1.0, 0.5, -0.5, -1.0]) / 3.0
+
+ polygons = npy.zeros((6, n, 2), float)
+ polygons[:,:nx1*ny1,0] = npy.repeat(npy.arange(nx1), ny1)
+ polygons[:,:nx1*ny1,1] = npy.array(range(ny1) * nx1)
+ polygons[:,nx1*ny1:,0] = npy.repeat(npy.arange(nx2) + 0.5, ny2)
+ polygons[:,nx1*ny1:,1] = npy.array(range(ny2) * nx2) + 0.5
+
+ polygons = npy.transpose(polygons, axes=[1,0,2])
+ polygons[:,:,0] *= sx
+ polygons[:,:,1] *= sy
+ polygons[:,:,0] += px
+ polygons[:,:,1] += py
+
+ if xscale=='log':
+ polygons[:,:,0] = npy.exp(polygons[:,:,0])
+ xmin = math.exp(xmin)
+ xmax = math.exp(xmax)
+ self.set_xscale('log')
+ if yscale=='log':
+ polygons[:,:,1] = npy.exp(polygons[:,:,1])
+ ymin = math.exp(ymin)
+ ymax = math.exp(ymax)
+ self.set_yscale('log')
+
+ class HexagonBinCollection(mcoll.PolyCollection):
+ """A HexagonBinCollection is a PolyCollection where the edge
+ colors are always kept equal to the fill colors"""
+ def update_scalarmappable(self):
+ mcoll.PolyCollection.update_scalarmappable(self)
+ self._edgecolors = self._facecolors
+
+ if edgecolors=='none':
+ collection = HexagonBinCollection(
+ polygons,
+ linewidths = linewidths,
+ transOffset = self.transData,
+ )
+ else:
+ collection = mcoll.PolyCollection(
+ polygons,
+ edgecolors = edgecolors,
+ linewidths = linewidths,
+ transOffset = self.transData,
+ )
+
+ # Transform the counts if needed
+ if bins=='log':
+ counts = npy.log(counts+1)
+ elif bins!=None:
+ if not iterable(bins):
+ minimum, maximum = min(counts), max(counts)
+ bins-=1 # one less edge than bins
+ bins = minimum + (maximum-minimum)*npy.arange(bins)/bins
+ bins = npy.sort(bins)
+ counts = bins.searchsorted(counts)
+
+ if norm is not None: assert(isinstance(norm, mcolors.Normalize))
+ if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))
+ collection.set_array(counts)
+ collection.set_cmap(cmap)
+ collection.set_norm(norm)
+ collection.set_alpha(alpha)
+ collection.update(kwargs)
+
+ if vmin is not None or vmax is not None:
+ collection.set_clim(vmin, vmax)
+ else:
+ collection.autoscale_None()
+
+ corners = ((xmin, ymin), (xmax, ymax))
+ self.update_datalim( corners)
+ self.autoscale_view()
+
+ # add the collection last
+ self.add_collection(collection)
+ return collection
+
+ hexbin.__doc__ = cbook.dedent(hexbin.__doc__) % martist.kwdocd
+
+
 def arrow(self, x, y, dx, dy, **kwargs):
 """
 Draws arrow on specified axis from (x,y) to (x+dx,y+dy).
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py	2008年04月28日 01:59:05 UTC (rev 5083)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py	2008年04月28日 07:24:33 UTC (rev 5084)
@@ -1953,6 +1953,27 @@
 
 # This function was autogenerated by boilerplate.py. Do not edit as
 # changes will be lost
+def hexbin(*args, **kwargs):
+ # allow callers to override the hold state by passing hold=True|False
+ b = ishold()
+ h = kwargs.pop('hold', None)
+ if h is not None:
+ hold(h)
+ try:
+ ret = gca().hexbin(*args, **kwargs)
+ draw_if_interactive()
+ except:
+ hold(b)
+ raise
+ gci._current = ret
+ hold(b)
+ return ret
+if Axes.hexbin.__doc__ is not None:
+ hexbin.__doc__ = dedent(Axes.hexbin.__doc__) + """
+Additional kwargs: hold = [True|False] overrides default hold state"""
+
+# This function was autogenerated by boilerplate.py. Do not edit as
+# changes will be lost
 def semilogx(*args, **kwargs):
 # allow callers to override the hold state by passing hold=True|False
 b = ishold()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5083
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5083&view=rev
Author: efiring
Date: 2008年04月27日 18:59:05 -0700 (2008年4月27日)
Log Message:
-----------
Fixed bug in last commit
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py	2008年04月28日 01:37:07 UTC (rev 5082)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py	2008年04月28日 01:59:05 UTC (rev 5083)
@@ -854,10 +854,12 @@
 
 
 if fill:
- self.set_color(store=0, *rgbFace[:3])
 if stroke:
- write("gsave\nfill\ngrestore\n")
+ write("gsave\n")
+ self.set_color(store=0, *rgbFace[:3])
+ write("fill\ngrestore\n")
 else:
+ self.set_color(store=0, *rgbFace[:3])
 write("fill\n")
 if stroke:
 write("stroke\n")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5082
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5082&view=rev
Author: efiring
Date: 2008年04月27日 18:37:07 -0700 (2008年4月27日)
Log Message:
-----------
Alternative fix for ps backend bug; removes superfluous gsave/grestores.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py	2008年04月28日 01:22:19 UTC (rev 5081)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py	2008年04月28日 01:37:07 UTC (rev 5082)
@@ -469,7 +469,7 @@
 def draw_path(self, gc, path, transform, rgbFace=None):
 """
 Draws a Path instance using the given affine transform.
-	"""
+ """
 ps = self._convert_path(path, transform)
 self._draw_ps(ps, gc, rgbFace)
 
@@ -744,10 +744,14 @@
 """ % locals()
 self._pswriter.write(ps)
 
- def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
+ def _draw_ps_oldstyle(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
 """
 Emit the PostScript sniplet 'ps' with all the attributes from 'gc'
 applied. 'ps' must consist of PostScript commands to construct a path.
+
+ This is the JDH-modified version of the original. It is kept
+ here now to facilitate checking the version below until we converge.
+
 """
 # local variable eliminates all repeated attribute lookups
 write = self._pswriter.write
@@ -777,15 +781,6 @@
 id = self._get_clip_path(clippath, clippath_trans)
 write('gsave\n%s\n' % id)
 
- needwrap = not (clippath or cliprect)
- if needwrap:
- # we need to make sure that there is at least 1
- # save/grestore around each ps write so we'll force it if
- # we're not getting one from the cliprecot or clippath.
- # hackish, yes
- write('gsave\n')
-
-
 # Jochen, is the strip necessary? - this could be a honking big string
 write(ps.strip())
 write("\n")
@@ -809,10 +804,68 @@
 write("grestore\n")
 if cliprect:
 write("grestore\n")
- if needwrap:
- write('grestore\n')
 
 
+ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
+ """
+ Emit the PostScript sniplet 'ps' with all the attributes from 'gc'
+ applied. 'ps' must consist of PostScript commands to construct a path.
+
+ The fill and/or stroke kwargs can be set to False if the
+ 'ps' string already includes filling and/or stroking, in
+ which case _draw_ps is just supplying properties and
+ clipping.
+ """
+ # local variable eliminates all repeated attribute lookups
+ write = self._pswriter.write
+ if debugPS and command:
+ write("% "+command+"\n")
+ write('gsave\n')
+ stroke = (stroke and gc.get_linewidth() > 0.0 and
+ (len(gc.get_rgb()) <= 3 or gc.get_rgb()[3] != 0.0))
+ fill = (fill and rgbFace is not None and
+ (len(rgbFace) <= 3 or rgbFace[3] != 0.0))
+
+ if stroke:
+ self.set_linewidth(gc.get_linewidth())
+ jint = gc.get_joinstyle()
+ self.set_linejoin(jint)
+ cint = gc.get_capstyle()
+ self.set_linecap(cint)
+ self.set_linedash(*gc.get_dashes())
+ self.set_color(*gc.get_rgb()[:3])
+
+ cliprect = gc.get_clip_rectangle()
+ if cliprect:
+ x,y,w,h=cliprect.bounds
+ write('%1.4g %1.4g %1.4g %1.4g clipbox\n' % (w,h,x,y))
+ clippath, clippath_trans = gc.get_clip_path()
+ if clippath:
+ id = self._get_clip_path(clippath, clippath_trans)
+ write('%s\n' % id)
+
+ # Jochen, is the strip necessary? - this could be a honking big string
+ write(ps.strip())
+ write("\n")
+
+ hatch = gc.get_hatch()
+ if hatch:
+ self.set_hatch(hatch)
+
+
+ if fill:
+ self.set_color(store=0, *rgbFace[:3])
+ if stroke:
+ write("gsave\nfill\ngrestore\n")
+ else:
+ write("fill\n")
+ if stroke:
+ write("stroke\n")
+
+ write("grestore\n")
+
+
+
 class GraphicsContextPS(GraphicsContextBase):
 def get_capstyle(self):
 return {'butt':0,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5081
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5081&view=rev
Author: jdh2358
Date: 2008年04月27日 18:22:19 -0700 (2008年4月27日)
Log Message:
-----------
fixed a ps path collection bug where cliprect and clipapth are none
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py	2008年04月28日 00:50:17 UTC (rev 5080)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py	2008年04月28日 01:22:19 UTC (rev 5081)
@@ -777,6 +777,15 @@
 id = self._get_clip_path(clippath, clippath_trans)
 write('gsave\n%s\n' % id)
 
+ needwrap = not (clippath or cliprect)
+ if needwrap:
+ # we need to make sure that there is at least 1
+ # save/grestore around each ps write so we'll force it if
+ # we're not getting one from the cliprecot or clippath.
+ # hackish, yes
+ write('gsave\n')
+
+
 # Jochen, is the strip necessary? - this could be a honking big string
 write(ps.strip())
 write("\n")
@@ -800,6 +809,8 @@
 write("grestore\n")
 if cliprect:
 write("grestore\n")
+ if needwrap:
+ write('grestore\n')
 
 
 class GraphicsContextPS(GraphicsContextBase):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2008年04月28日 00:50:25
Revision: 5080
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5080&view=rev
Author: efiring
Date: 2008年04月27日 17:50:17 -0700 (2008年4月27日)
Log Message:
-----------
Fix invalid title string that broke ps output
Modified Paths:
--------------
 trunk/matplotlib/examples/nan_test.py
Modified: trunk/matplotlib/examples/nan_test.py
===================================================================
--- trunk/matplotlib/examples/nan_test.py	2008年04月27日 07:55:03 UTC (rev 5079)
+++ trunk/matplotlib/examples/nan_test.py	2008年04月28日 00:50:17 UTC (rev 5080)
@@ -11,10 +11,7 @@
 
 xlabel('time (s)')
 ylabel('voltage (mV)')
-title('A sine wave with a gap of NaN\'s between 0.4 and 0.6')
+title('A sine wave with a gap of NaNs between 0.4 and 0.6')
 grid(True)
 
-#savefig('simple_plot.png')
-savefig('nan_test')
-
 show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2008年04月27日 07:55:07
Revision: 5079
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5079&view=rev
Author: efiring
Date: 2008年04月27日 00:55:03 -0700 (2008年4月27日)
Log Message:
-----------
Handle changed dpi in quiver; remove extra draw in print_figure.
There is still a dpi-related problem with mathtext in the QuiverKey label.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backend_bases.py
 trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
 trunk/matplotlib/lib/matplotlib/mathtext.py
 trunk/matplotlib/lib/matplotlib/quiver.py
 trunk/matplotlib/lib/matplotlib/text.py
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py	2008年04月27日 02:27:01 UTC (rev 5078)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py	2008年04月27日 07:55:03 UTC (rev 5079)
@@ -1088,8 +1088,7 @@
 self.figure.set_facecolor(origfacecolor)
 self.figure.set_edgecolor(origedgecolor)
 self.figure.set_canvas(self)
- self.figure.canvas.draw()
-
+ #self.figure.canvas.draw() ## seems superfluous
 return result
 
 def get_default_filetype(self):
@@ -1509,7 +1508,7 @@
 if not self._xypress: return
 
 last_a = []
- 
+
 for cur_xypress in self._xypress:
 x, y = event.x, event.y
 lastx, lasty, a, ind, lim, trans = cur_xypress
@@ -1528,7 +1527,7 @@
 x, y = inverse.transform_point( (x, y) )
 Xmin,Xmax=a.get_xlim()
 Ymin,Ymax=a.get_ylim()
- 
+
 # detect twinx,y axes and avoid double zooming
 twinx, twiny = False, False
 if last_a:
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py	2008年04月27日 02:27:01 UTC (rev 5078)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py	2008年04月27日 07:55:03 UTC (rev 5079)
@@ -59,8 +59,7 @@
 self.width = width
 self.height = height
 if __debug__: verbose.report('RendererAgg.__init__ width=%s, height=%s'%(width, height), 'debug-annoying')
- self._renderer = _RendererAgg(int(width), int(height), dpi,
-				 debug=False)
+ self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
 if __debug__: verbose.report('RendererAgg.__init__ _RendererAgg done',
 'debug-annoying')
 self.draw_path = self._renderer.draw_path
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2008年04月27日 02:27:01 UTC (rev 5078)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2008年04月27日 07:55:03 UTC (rev 5079)
@@ -1438,8 +1438,8 @@
 w: specifies a width
 m: is either 'exactly' or 'additional'.
 
- Thus, hpack(w, exactly) produces a box whose width is exactly w, while
- hpack (w, additional ) yields a box whose width is the natural width
+ Thus, hpack(w, 'exactly') produces a box whose width is exactly w, while
+ hpack (w, 'additional') yields a box whose width is the natural width
 plus w. The default values produce a box with the natural width.
 node644, node649"""
 # I don't know why these get reset in TeX. Shift_amount is pretty
@@ -1502,8 +1502,8 @@
 m: is either 'exactly' or 'additional'.
 l: a maximum height
 
- Thus, vpack(h, exactly) produces a box whose width is exactly w, while
- vpack(w, additional) yields a box whose width is the natural width
+ Thus, vpack(h, 'exactly') produces a box whose width is exactly w, while
+ vpack(w, 'additional') yields a box whose width is the natural width
 plus w. The default values produce a box with the natural width.
 node644, node668"""
 # I don't know why these get reset in TeX. Shift_amount is pretty
@@ -2678,7 +2678,6 @@
 def parse(self, s, dpi = 72, prop = None):
 if prop is None:
 prop = FontProperties()
-
 cacheKey = (s, dpi, hash(prop))
 result = self._cache.get(cacheKey)
 if result is not None:
Modified: trunk/matplotlib/lib/matplotlib/quiver.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/quiver.py	2008年04月27日 02:27:01 UTC (rev 5078)
+++ trunk/matplotlib/lib/matplotlib/quiver.py	2008年04月27日 07:55:03 UTC (rev 5079)
@@ -168,20 +168,24 @@
 self.coord = kw.pop('coordinates', 'axes')
 self.color = kw.pop('color', None)
 self.label = label
- self.labelsep = (kw.pop('labelsep', 0.1) * Q.ax.figure.dpi)
+ self._labelsep_inches = kw.pop('labelsep', 0.1)
+ self.labelsep = (self._labelsep_inches * Q.ax.figure.dpi)
 
 def on_dpi_change(fig):
- self.labelsep = (kw.pop('labelsep', 0.1) * fig.dpi)
+ self.labelsep = (self._labelsep_inches * fig.dpi)
+ self._initialized = False # simple brute force update
+ # works because _init is called
+ # at the start of draw.
 
 Q.ax.figure.callbacks.connect('dpi_changed', on_dpi_change)
 
-
 self.labelpos = kw.pop('labelpos', 'N')
 self.labelcolor = kw.pop('labelcolor', None)
 self.fontproperties = kw.pop('fontproperties', dict())
 self.kw = kw
 _fp = self.fontproperties
- self.text = text.Text(text=label,
+ #boxprops = dict(facecolor='red')
+ self.text = text.Text(text=label, # bbox=boxprops,
 horizontalalignment=self.halign[self.labelpos],
 verticalalignment=self.valign[self.labelpos],
 fontproperties=font_manager.FontProperties(**_fp))
@@ -297,6 +301,16 @@
 self.keyvec = None
 self.keytext = None
 
+ def on_dpi_change(fig):
+ self._new_UV = True # vertices depend on width, span
+ # which in turn depend on dpi
+ self._initialized = False # simple brute force update
+ # works because _init is called
+ # at the start of draw.
+
+ self.ax.figure.callbacks.connect('dpi_changed', on_dpi_change)
+
+
 __init__.__doc__ = """
 The constructor takes one required argument, an Axes
 instance, followed by the args and kwargs described
@@ -331,7 +345,8 @@
 if not self._initialized:
 trans = self._set_transform()
 ax = self.ax
- sx, sy = trans.inverted().transform_point((ax.bbox.width, ax.bbox.height))
+ sx, sy = trans.inverted().transform_point(
+ (ax.bbox.width, ax.bbox.height))
 self.span = sx
 sn = max(8, min(25, math.sqrt(self.N)))
 if self.width is None:
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py	2008年04月27日 02:27:01 UTC (rev 5078)
+++ trunk/matplotlib/lib/matplotlib/text.py	2008年04月27日 07:55:03 UTC (rev 5079)
@@ -1174,7 +1174,6 @@
 if self.arrowprops:
 x0, y0 = x, y
 l,b,w,h = self.get_window_extent(renderer).bounds
- dpi = self.figure.dpi
 r = l+w
 t = b+h
 xc = 0.5*(l+r)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年04月27日 02:27:06
Revision: 5078
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5078&view=rev
Author: jdh2358
Date: 2008年04月26日 19:27:01 -0700 (2008年4月26日)
Log Message:
-----------
removed backend_agg2
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_template.py
Removed Paths:
-------------
 trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py
Deleted: trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py	2008年04月26日 21:59:17 UTC (rev 5077)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py	2008年04月27日 02:27:01 UTC (rev 5078)
@@ -1,206 +0,0 @@
-"""
-An agg http://antigrain.com/ backend
-
-"""
-from __future__ import division
-
-import os, sys
-import matplotlib.agg as agg
-
-from matplotlib import verbose
-
-from matplotlib._pylab_helpers import Gcf
-from matplotlib.backend_bases import RendererBase,\
- GraphicsContextBase, FigureManagerBase, FigureCanvasBase
-
-from matplotlib.cbook import enumerate, is_string_like, exception_to_str
-from matplotlib.figure import Figure
-from matplotlib.ft2font import FT2Font
-from matplotlib.mathtext import MathTextParser
-
-
-from _backend_agg import RendererAgg as _RendererAgg
-
-backend_version = 'v2.2'
-_fontd = {} # a map from fname to font instances
-
-
-class RendererAgg(RendererBase):
- """
- The renderer handles all the drawing primitives using a graphics
- context instance that controls the colors/styles
- """
-
- debug=1
- def __init__(self, width, height, dpi):
- if __debug__: verbose.report('RendererAgg.__init__', 'debug-annoying')
- self.dpi = dpi
- self.width = int(width)
- self.height = int(height)
-
- stride = self.width*4
- self.buffer = agg.buffer(self.width, self.height, stride)
-
- self.rbuf = agg.rendering_buffer()
- self.rbuf.attachb(self.buffer)
-
- self.pf = agg.pixel_format(self.rbuf)
- self.rbase = agg.renderer_base(self.pf)
-
- self.rasterizer = agg.rasterizer_scanline_aa()
- self.scanline = agg.scanline_p8()
- self.renderer = agg.renderer_scanline_aa_solid(self.rbase);
-
-
- def draw_lines(self, gc, x, y, trans):
- """
- x and y are equal length arrays, draw lines connecting each
- point in x, y
- """
-
- x, y = trans.numerix_x_y(x,y)
- if len(x)<2: return
- path = agg.path_storage()
- path.move_to(x[0],self.height-y[0])
- for i in xrange(1, len(x)):
- path.line_to(x[i],self.height-y[i])
-
- stroke = agg.conv_stroke(path)
- stroke.width(1.0)
- r,g,b = [int(255*val) for val in gc.get_rgb()]
- a = int(255*gc.get_alpha())
-
- color = agg.rgba8(r,g,b,a)
- self.renderer.color( color )
- self.rasterizer.add_path(stroke)
- agg.render_scanlines(self.rasterizer, self.scanline, self.renderer);
-
- def draw_markers(self, gc, path, rgbFace, xt, yt, trans):
- pass
-
- def draw_arc(self, gcEdge, rgbFace, x, y, width, height, angle1, angle2, rotation):
- pass
-
- def draw_image(self, x, y, im, origin, bbox):
- pass
-
- def draw_line(self, gc, x1, y1, x2, y2):
- pass
-
- def draw_point(self, gc, x, y):
- pass
-
- def draw_polygon(self, gcEdge, rgbFace, points):
- pass
-
- def draw_rectangle(self, gcEdge, rgbFace, x, y, width, height):
- pass
-
- def draw_text(self, gc, x, y, s, prop, angle, ismath=False):
- pass
-
- def flipy(self):
- return True
-
- def get_canvas_width_height(self):
- return 100, 100
-
- def get_text_width_height(self, s, prop, ismath):
- return 1, 1
-
- def new_gc(self):
- return GraphicsContextBase()
-
-
- def points_to_pixels(self, points):
- """
- convert point measures to pixes using dpi and the pixels per
- inch of the display
- """
- if __debug__: verbose.report('RendererAgg.points_to_pixels', 'debug-annoying')
- return points*self.dpi.get()/72.0
-
-
-
-
-
-def new_figure_manager(num, *args, **kwargs):
- """
- Create a new figure manager instance
- """
- if __debug__: verbose.report('backend_agg.new_figure_manager', 'debug-annoying')
- FigureClass = kwargs.pop('FigureClass', Figure)
- thisFig = FigureClass(*args, **kwargs)
- canvas = FigureCanvasAgg(thisFig)
- manager = FigureManagerBase(canvas, num)
- return manager
-
-
-class FigureCanvasAgg(FigureCanvasBase):
- """
- The canvas the figure renders into. Calls the draw and print fig
- methods, creates the renderers, etc...
-
- Public attribute
-
- figure - A Figure instance
- """
-
-
-
- def draw(self):
- """
- Draw the figure using the renderer
- """
- if __debug__: verbose.report('FigureCanvasAgg.draw', 'debug-annoying')
-
- renderer = self.get_renderer()
- self.figure.draw(renderer)
- return renderer
-
- def get_renderer(self):
- l,b,w,h = self.figure.bbox.get_bounds()
- key = w, h, self.figure.dpi.get()
- try: self._lastKey, self.renderer
- except AttributeError: need_new_renderer = True
- else: need_new_renderer = (self._lastKey != key)
-
- if need_new_renderer:
- self.renderer = RendererAgg(w, h, self.figure.dpi)
- self._lastKey = key
- return self.renderer
-
- def tostring_rgb(self):
- if __debug__: verbose.report('FigureCanvasAgg.tostring_rgb', 'debug-annoying')
- return self.renderer.tostring_rgb()
-
- def tostring_argb(self):
- if __debug__: verbose.report('FigureCanvasAgg.tostring_argb', 'debug-annoying')
- return self.renderer.tostring_argb()
-
- def buffer_rgba(self,x,y):
- if __debug__: verbose.report('FigureCanvasAgg.buffer_rgba', 'debug-annoying')
- return self.renderer.buffer_rgba(x,y)
-
-
- def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
- orientation='portrait', **kwargs):
- """
- Render the figure to hardcopy. Set the figure patch face and
- edge colors. This is useful because some of the GUIs have a
- gray figure face color background and you'll probably want to
- override this on hardcopy
-
- If the extension matches PNG, write a PNG file
-
- If the extension matches BMP or RAW, write an RGBA bitmap file
-
- If filename is a fileobject, write png to file object (thus
- you can, for example, write the png to stdout
- """
-
- r = self.draw()
- s = r.buffer.to_string()
- import Image
- im = Image.fromstring( "RGBA", (r.width, r.height), s)
- im.show()
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_template.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_template.py	2008年04月26日 21:59:17 UTC (rev 5077)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_template.py	2008年04月27日 02:27:01 UTC (rev 5078)
@@ -68,13 +68,15 @@
 def draw_path(self, gc, path, transform, rgbFace=None):
 pass
 
- # draw_markers is optional, and we get more correct
- # relative timings by leaving it out.
+ # draw_markers is optional, and we get more correct relative
+ # timings by leaving it out. backend implementers concerned with
+ # performance will probably want to implement it
 # def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None):
 # pass
 
 # draw_path_collection is optional, and we get more correct
- # relative timings by leaving it out.
+ # relative timings by leaving it out. backend implementers concerned with
+ # performance will probably want to implement it
 # def draw_path_collection(self, master_transform, cliprect, clippath,
 # clippath_trans, paths, all_transforms, offsets,
 # offsetTrans, facecolors, edgecolors, linewidths,
@@ -82,7 +84,8 @@
 # pass
 
 # draw_quad_mesh is optional, and we get more correct
- # relative timings by leaving it out.
+ # relative timings by leaving it out. backend implementers concerned with
+ # performance will probably want to implement it
 # def draw_quad_mesh(self, master_transform, cliprect, clippath,
 # clippath_trans, meshWidth, meshHeight, coordinates,
 # offsets, offsetTrans, facecolors, antialiased,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年04月26日 21:59:20
Revision: 5077
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5077&view=rev
Author: jdh2358
Date: 2008年04月26日 14:59:17 -0700 (2008年4月26日)
Log Message:
-----------
added a dpi callback to the quiver key
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/quiver.py
Modified: trunk/matplotlib/lib/matplotlib/quiver.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/quiver.py	2008年04月26日 21:46:52 UTC (rev 5076)
+++ trunk/matplotlib/lib/matplotlib/quiver.py	2008年04月26日 21:59:17 UTC (rev 5077)
@@ -169,6 +169,13 @@
 self.color = kw.pop('color', None)
 self.label = label
 self.labelsep = (kw.pop('labelsep', 0.1) * Q.ax.figure.dpi)
+
+ def on_dpi_change(fig):
+ self.labelsep = (kw.pop('labelsep', 0.1) * fig.dpi)
+
+ Q.ax.figure.callbacks.connect('dpi_changed', on_dpi_change)
+
+
 self.labelpos = kw.pop('labelpos', 'N')
 self.labelcolor = kw.pop('labelcolor', None)
 self.fontproperties = kw.pop('fontproperties', dict())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年04月26日 21:46:54
Revision: 5076
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5076&view=rev
Author: jdh2358
Date: 2008年04月26日 14:46:52 -0700 (2008年4月26日)
Log Message:
-----------
fixed dpi figure title positioning problem
Modified Paths:
--------------
 trunk/matplotlib/CODING_GUIDE
 trunk/matplotlib/Makefile
 trunk/matplotlib/examples/barchart_demo.py
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/figure.py
 trunk/matplotlib/lib/matplotlib/pyplot.py
 trunk/matplotlib/lib/matplotlib/text.py
Modified: trunk/matplotlib/CODING_GUIDE
===================================================================
--- trunk/matplotlib/CODING_GUIDE	2008年04月25日 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/CODING_GUIDE	2008年04月26日 21:46:52 UTC (rev 5076)
@@ -45,8 +45,8 @@
 
 For numpy, use:
 
- import numpy as npy
- a = npy.array([1,2,3])
+ import numpy as np
+ a = np.array([1,2,3])
 
 
 For masked arrays, use:
Modified: trunk/matplotlib/Makefile
===================================================================
--- trunk/matplotlib/Makefile	2008年04月25日 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/Makefile	2008年04月26日 21:46:52 UTC (rev 5076)
@@ -10,7 +10,7 @@
 RELEASE = matplotlib-${VERSION}
 
 
-clean: 
+clean:
 	${PYTHON} setup.py clean;\
 	rm -f *.png *.ps *.eps *.svg *.jpg *.pdf
 	find . -name "_tmp*.py" | xargs rm -f;\
@@ -25,11 +25,12 @@
 	${PYTHON} license.py ${VERSION} license/LICENSE;\
 	${PYTHON} setup.py sdist --formats=gztar,zip;
 
-pyback: 
-	tar cvfz pyback.tar.gz *.py lib src examples/*.py unit/*.py 
+pyback:
+	tar cvfz pyback.tar.gz *.py lib src examples/*.py unit/*.py
 
 
+build_osx105:
+	CFLAGS="-Os -arch i386 -arch ppc" LDFLAGS="-Os -arch i386 -arch ppc" python setup.py build
 
 
 
-
Modified: trunk/matplotlib/examples/barchart_demo.py
===================================================================
--- trunk/matplotlib/examples/barchart_demo.py	2008年04月25日 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/examples/barchart_demo.py	2008年04月26日 21:46:52 UTC (rev 5076)
@@ -1,24 +1,39 @@
+
 #!/usr/bin/env python
 # a bar plot with errorbars
-from pylab import *
+import numpy as np
+import matplotlib.pyplot as plt
 
 N = 5
 menMeans = (20, 35, 30, 35, 27)
 menStd = (2, 3, 4, 1, 2)
 
-ind = arange(N) # the x locations for the groups
+ind = np.arange(N) # the x locations for the groups
 width = 0.35 # the width of the bars
-p1 = bar(ind, menMeans, width, color='r', yerr=menStd)
 
+fig = plt.figure()
+ax = fig.add_subplot(111)
+rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)
+
 womenMeans = (25, 32, 34, 20, 25)
 womenStd = (3, 5, 2, 3, 3)
-p2 = bar(ind+width, womenMeans, width, color='y', yerr=womenStd)
+rects2 = ax.bar(ind+width, womenMeans, width, color='y', yerr=womenStd)
 
-ylabel('Scores')
-title('Scores by group and gender')
-xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5') )
+# add some
+ax.set_ylabel('Scores')
+ax.set_title('Scores by group and gender')
+ax.set_xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5') )
 
-legend( (p1[0], p2[0]), ('Men', 'Women') )
+ax.legend( (rects1[0], rects2[0]), ('Men', 'Women') )
 
-#savefig('barchart_demo')
-show()
+def autolabel(rects):
+ # attach some text labels
+ for rect in rects:
+ height = rect.get_height()
+ ax.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height),
+ ha='center', va='bottom')
+
+autolabel(rects1)
+autolabel(rects2)
+#fig.savefig('barchart_demo')
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2008年04月25日 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2008年04月26日 21:46:52 UTC (rev 5076)
@@ -780,7 +780,10 @@
 
 self.grid(self._gridOn)
 props = font_manager.FontProperties(size=rcParams['axes.titlesize'])
- self.titleOffsetTrans = mtransforms.Affine2D().translate(0.0, 10.0)
+
+
+ self.titleOffsetTrans = mtransforms.Affine2D().translate(
+ 0.0, 5.0*self.figure.dpi/72.)
 self.title = mtext.Text(
 x=0.5, y=1.0, text='',
 fontproperties=props,
@@ -811,8 +814,17 @@
 self.xaxis.set_clip_path(self.axesPatch)
 self.yaxis.set_clip_path(self.axesPatch)
 
- self.titleOffsetTrans.clear().translate(0.0, 10.0)
+ self.titleOffsetTrans.clear().translate(
+ 0.0, 5.0*self.figure.dpi/72.)
 
+ def on_dpi_change(fig):
+ self.titleOffsetTrans.clear().translate(
+ 0.0, 5.0*fig.dpi/72.)
+
+ self.figure.callbacks.connect('dpi_changed', on_dpi_change)
+
+
+
 def clear(self):
 'clear the axes'
 self.cla()
@@ -839,8 +851,10 @@
 figure will be cleared on the next plot command
 
 """
- if b is None: self._hold = not self._hold
- else: self._hold = b
+ if b is None:
+ self._hold = not self._hold
+ else:
+ self._hold = b
 
 def get_aspect(self):
 return self._aspect
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py	2008年04月25日 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/lib/matplotlib/figure.py	2008年04月26日 21:46:52 UTC (rev 5076)
@@ -1,7 +1,7 @@
 """
 Figure class -- add docstring here!
 """
-import numpy as npy
+import numpy as np
 import time
 
 import artist
@@ -20,6 +20,8 @@
 from projections import projection_factory, get_projection_names, \
 get_projection_class
 
+import matplotlib.cbook as cbook
+
 class SubplotParams:
 """
 A class to hold the parameters for a subplot
@@ -176,6 +178,13 @@
 
 class Figure(Artist):
 
+ """
+ The Figure instance supports callbacks through a callbacks
+ attribute which is a cbook.CallbackRegistry instance. The events
+ you can connect to are 'dpi_changed', and the callback will be
+ called with func(fig) where fig is the Figure instance
+ """
+
 def __str__(self):
 return "Figure(%gx%g)" % tuple(self.bbox.size)
 
@@ -195,6 +204,8 @@
 """
 Artist.__init__(self)
 
+ self.callbacks = cbook.CallbackRegistry(('dpi_changed', ))
+
 if figsize is None : figsize = rcParams['figure.figsize']
 if dpi is None : dpi = rcParams['figure.dpi']
 if facecolor is None: facecolor = rcParams['figure.facecolor']
@@ -236,6 +247,7 @@
 def _set_dpi(self, dpi):
 self._dpi = dpi
 self.dpi_scale_trans.clear().scale(dpi, dpi)
+ self.callbacks.process('dpi_changed', self)
 dpi = property(_get_dpi, _set_dpi)
 
 def enable_auto_layout(self, setting=True):
@@ -255,7 +267,7 @@
 rotation: the rotation of the xtick labels
 ha : the horizontal alignment of the xticklabels
 """
- allsubplots = npy.alltrue([hasattr(ax, 'is_last_row') for ax in self.axes])
+ allsubplots = np.alltrue([hasattr(ax, 'is_last_row') for ax in self.axes])
 if len(self.axes)==1:
 for label in ax.get_xticklabels():
 label.set_ha(ha)
@@ -662,6 +674,9 @@
 """
 Clear the figure
 """
+
+ self.callbacks = cbook.CallbackRegistry(('dpi_changed', ))
+
 for ax in tuple(self.axes): # Iterate over the copy.
 ax.cla()
 self.delaxes(ax) # removes ax from self.axes
@@ -1022,8 +1037,8 @@
 
 # min/max sizes to respect when autoscaling. If John likes the idea, they
 # could become rc parameters, for now they're hardwired.
- figsize_min = npy.array((4.0,2.0)) # min length for width/height
- figsize_max = npy.array((16.0,16.0)) # max length for width/height
+ figsize_min = np.array((4.0,2.0)) # min length for width/height
+ figsize_max = np.array((16.0,16.0)) # max length for width/height
 #figsize_min = rcParams['figure.figsize_min']
 #figsize_max = rcParams['figure.figsize_max']
 
@@ -1038,7 +1053,7 @@
 fig_height = rcParams['figure.figsize'][1]
 
 # New size for the figure, keeping the aspect ratio of the caller
- newsize = npy.array((fig_height/arr_ratio,fig_height))
+ newsize = np.array((fig_height/arr_ratio,fig_height))
 
 # Sanity checks, don't drop either dimension below figsize_min
 newsize /= min(1.0,*(newsize/figsize_min))
@@ -1048,7 +1063,7 @@
 
 # Finally, if we have a really funky aspect ratio, break it but respect
 # the min/max dimensions (we don't want figures 10 feet tall!)
- newsize = npy.clip(newsize,figsize_min,figsize_max)
+ newsize = np.clip(newsize,figsize_min,figsize_max)
 return newsize
 
 artist.kwdocd['Figure'] = artist.kwdoc(Figure)
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py	2008年04月25日 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py	2008年04月26日 21:46:52 UTC (rev 5076)
@@ -274,9 +274,9 @@
 
 def ginput(*args, **kwargs):
 """
- Blocking call to interact with the figure. 
+ Blocking call to interact with the figure.
 
- This will wait for n clicks from the user and return a list of the 
+ This will wait for n clicks from the user and return a list of the
 coordinates of each click.
 
 If timeout is negative, does not timeout.
@@ -345,8 +345,17 @@
 will be cleared on the next plot command
 """
 
- gcf().hold(b)
- gca().hold(b)
+ fig = gcf()
+ ax = fig.gca()
+
+ fig.hold(b)
+ ax.hold(b)
+
+ # b=None toggles the hold state, so let's get get the current hold
+ # state; but should pyplot hold toggle the rc setting - me thinks
+ # not
+ b = ax.ishold()
+
 rc('axes', hold=b)
 
 def ishold():
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py	2008年04月25日 16:45:30 UTC (rev 5075)
+++ trunk/matplotlib/lib/matplotlib/text.py	2008年04月26日 21:46:52 UTC (rev 5076)
@@ -4,7 +4,7 @@
 from __future__ import division
 import math
 
-import numpy as npy
+import numpy as np
 
 from matplotlib import cbook
 from matplotlib import rcParams
@@ -180,8 +180,8 @@
 width, height = 0.0, 0.0
 lines = self._text.split('\n')
 
- whs = npy.zeros((len(lines), 2))
- horizLayout = npy.zeros((len(lines), 4))
+ whs = np.zeros((len(lines), 2))
+ horizLayout = np.zeros((len(lines), 4))
 
 # Find full vertical extent of font,
 # including ascenders and descenders:
@@ -208,7 +208,7 @@
 # get the rotation matrix
 M = Affine2D().rotate_deg(self.get_rotation())
 
- offsetLayout = npy.zeros((len(lines), 2))
+ offsetLayout = np.zeros((len(lines), 2))
 offsetLayout[:] = horizLayout[:, 0:2]
 # now offset the individual text lines within the box
 if len(lines)>1: # do the multiline aligment
@@ -219,9 +219,9 @@
 offsetLayout[:, 0] += width - horizLayout[:, 2]
 
 # the corners of the unrotated bounding box
- cornersHoriz = npy.array(
+ cornersHoriz = np.array(
 [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)],
- npy.float_)
+ np.float_)
 # now rotate the bbox
 cornersRotated = M.transform(cornersHoriz)
 
@@ -658,7 +658,7 @@
 dashlength is the length of the dash in canvas units.
 (default=0.0).
 
- dashdirection is one of 0 or 1, npy.where 0 draws the dash
+ dashdirection is one of 0 or 1, np.where 0 draws the dash
 after the text and 1 before.
 (default=0).
 
@@ -782,15 +782,15 @@
 dashpush = self.get_dashpush()
 
 angle = get_rotation(dashrotation)
- theta = npy.pi*(angle/180.0+dashdirection-1)
- cos_theta, sin_theta = npy.cos(theta), npy.sin(theta)
+ theta = np.pi*(angle/180.0+dashdirection-1)
+ cos_theta, sin_theta = np.cos(theta), np.sin(theta)
 
 transform = self.get_transform()
 
 # Compute the dash end points
 # The 'c' prefix is for canvas coordinates
 cxy = transform.transform_point((dashx, dashy))
- cd = npy.array([cos_theta, sin_theta])
+ cd = np.array([cos_theta, sin_theta])
 c1 = cxy+dashpush*cd
 c2 = cxy+(dashpush+dashlength)*cd
 
@@ -829,8 +829,8 @@
 if dy > h or dy < -h:
 dy = h
 dx = h/tan_theta
- cwd = npy.array([dx, dy])/2
- cwd *= 1+dashpad/npy.sqrt(npy.dot(cwd,cwd))
+ cwd = np.array([dx, dy])/2
+ cwd *= 1+dashpad/np.sqrt(np.dot(cwd,cwd))
 cw = c2+(dashdirection*2-1)*cwd
 
 newx, newy = inverse.transform_point(tuple(cw))
@@ -840,7 +840,7 @@
 # I'm not at all sure this is the right way to do this.
 we = Text.get_window_extent(self, renderer=renderer)
 self._twd_window_extent = we.frozen()
- self._twd_window_extent.update_from_data_xy(npy.array([c1]), False)
+ self._twd_window_extent.update_from_data_xy(np.array([c1]), False)
 
 # Finally, make text align center
 Text.set_horizontalalignment(self, 'center')
@@ -1094,8 +1094,8 @@
 return x, y
 elif s=='polar':
 theta, r = x, y
- x = r*npy.cos(theta)
- y = r*npy.sin(theta)
+ x = r*np.cos(theta)
+ y = r*np.cosmsin(theta)
 trans = self.axes.transData
 return trans.transform_point((x,y))
 elif s=='figure points':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing results of 74

1 2 3 > >> (Page 1 of 3)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /