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
|
|
From: <md...@us...> - 2008-07-03 16:09:29
|
Revision: 5711
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5711&view=rev
Author: mdboom
Date: 2008-07-03 09:08:52 -0700 (Thu, 03 Jul 2008)
Log Message:
-----------
O(n) implementation of Grouper.__iter__
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/cbook.py
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py 2008-07-03 14:30:41 UTC (rev 5710)
+++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-07-03 16:08:52 UTC (rev 5711)
@@ -1030,7 +1030,7 @@
>>> g.join('a', 'b')
>>> g.join('b', 'c')
>>> g.join('d', 'e')
- >>> list(g.get())
+ >>> list(g)
[['a', 'b', 'c'], ['d', 'e']]
>>> g.joined('a', 'b')
True
@@ -1079,14 +1079,25 @@
def __iter__(self):
"""
- Returns an iterator yielding each of the disjoint sets as a list.
+ Iterate over each of the disjoint sets as a list.
+
+ The iterator is invalid if interleaved with calls to join().
"""
- seen = set()
- for elem, group in self._mapping.iteritems():
- if elem not in seen:
+ class Token: pass
+ token = Token()
+
+ # Mark each group as we come across if by appending a token,
+ # and don't yield it twice
+ for group in self._mapping.itervalues():
+ if not group[-1] is token:
yield group
- seen.update(group)
+ group.append(token)
+ # Cleanup the tokens
+ for group in self._mapping.itervalues():
+ if group[-1] is token:
+ del group[-1]
+
def get_siblings(self, a):
"""
Returns all of the items joined with *a*, including itself.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-07-03 14:30:42
|
Revision: 5710
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5710&view=rev
Author: jdh2358
Date: 2008-07-03 07:30:41 -0700 (Thu, 03 Jul 2008)
Log Message:
-----------
added findobj
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/findobj_demo.py
Modified: trunk/matplotlib/examples/pylab_examples/findobj_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/findobj_demo.py 2008-07-03 14:30:13 UTC (rev 5709)
+++ trunk/matplotlib/examples/pylab_examples/findobj_demo.py 2008-07-03 14:30:41 UTC (rev 5710)
@@ -1,3 +1,6 @@
+"""
+Recursuvely find all objects that match some criteria
+"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.text as text
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-07-03 14:30:16
|
Revision: 5709
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5709&view=rev
Author: jdh2358
Date: 2008-07-03 07:30:13 -0700 (Thu, 03 Jul 2008)
Log Message:
-----------
added findobj
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/artist.py
trunk/matplotlib/lib/matplotlib/cbook.py
trunk/matplotlib/lib/matplotlib/legend.py
trunk/matplotlib/lib/matplotlib/pylab.py
trunk/matplotlib/lib/matplotlib/pyplot.py
Added Paths:
-----------
trunk/matplotlib/examples/pylab_examples/findobj_demo.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-07-03 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/CHANGELOG 2008-07-03 14:30:13 UTC (rev 5709)
@@ -1,3 +1,6 @@
+2007-07-03 Implemented findobj method for artist and pyplot - see
+ examples/pylab_examples/findobj_demo.py - JDH
+
2008-06-30 Another attempt to fix TextWithDash - DSD
2008-06-30 Removed Qt4 NavigationToolbar2.destroy -- it appears to
Added: trunk/matplotlib/examples/pylab_examples/findobj_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/findobj_demo.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/findobj_demo.py 2008-07-03 14:30:13 UTC (rev 5709)
@@ -0,0 +1,34 @@
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.text as text
+
+a = np.arange(0,3,.02)
+b = np.arange(0,3,.02)
+c = np.exp(a)
+d = c[::-1]
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+plt.plot(a,c,'k--',a,d,'k:',a,c+d,'k')
+plt.legend(('Model length', 'Data length', 'Total message length'),
+ 'upper center', shadow=True)
+plt.ylim([-1,20])
+plt.grid(False)
+plt.xlabel('Model complexity --->')
+plt.ylabel('Message length --->')
+plt.title('Minimum Message Length')
+
+# match on arbitrary function
+def myfunc(x):
+ return hasattr(x, 'set_color')
+
+for o in fig.findobj(myfunc):
+ o.set_color('blue')
+
+# match on class instances
+for o in fig.findobj(text.Text):
+ o.set_fontstyle('italic')
+
+
+
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/artist.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/artist.py 2008-07-03 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/artist.py 2008-07-03 14:30:13 UTC (rev 5709)
@@ -508,7 +508,47 @@
ret.extend( [func(v)] )
return ret
+ def findobj(self, match=None):
+ """
+ recursively find all :class:matplotlib.artist.Artist instances
+ contained in self
+ *match* can be
+
+ - None: return all objects contained in artist (including artist)
+
+ - function with signature ``boolean = match(artist)`` used to filter matches
+
+ - class instance: eg Line2D. Only return artists of class type
+ """
+
+ if match is None: # always return True
+ def matchfunc(x): return True
+ elif cbook.issubclass_safe(match, Artist):
+ def matchfunc(x):
+ return isinstance(x, match)
+ elif callable(match):
+ matchfunc = match
+ else:
+ raise ValueError('match must be None, an matplotlib.artist.Artist subclass, or a callable')
+
+
+ artists = []
+ if hasattr(self, 'get_children'):
+ for c in self.get_children():
+ if matchfunc(c):
+ artists.append(c)
+ artists.extend([thisc for thisc in c.findobj(matchfunc) if matchfunc(thisc)])
+ else:
+ if matchfunc(self):
+ artists.append(self)
+ return artists
+
+
+
+
+
+
class ArtistInspector:
"""
A helper class to inspect an :class:`~matplotlib.artist.Artist`
@@ -690,6 +730,48 @@
return lines
+
+ def findobj(self, match=None):
+ """
+ recursively find all :class:matplotlib.artist.Artist instances
+ contained in self
+
+ if *match* is not None, it can be
+
+ - function with signature ``boolean = match(artist)``
+
+ - class instance: eg Line2D
+
+ used to filter matches
+ """
+
+ if match is None: # always return True
+ def matchfunc(x): return True
+ elif issubclass(match, Artist):
+ def matchfunc(x):
+ return isinstance(x, match)
+ elif callable(match):
+ matchfunc = func
+ else:
+ raise ValueError('match must be None, an matplotlib.artist.Artist subclass, or a callable')
+
+
+ artists = []
+ if hasattr(self, 'get_children'):
+ for c in self.get_children():
+ if matchfunc(c):
+ artists.append(c)
+ artists.extend([thisc for thisc in c.findobj(matchfunc) if matchfunc(thisc)])
+ else:
+ if matchfunc(self):
+ artists.append(self)
+ return artists
+
+
+
+
+
+
def getp(o, property=None):
"""
Return the value of handle property. property is an optional string
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py 2008-07-03 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-07-03 14:30:13 UTC (rev 5709)
@@ -886,7 +886,14 @@
raise ValueError(_safezip_msg % (Nx, i+1, len(arg)))
return zip(*args)
+def issubclass_safe(x, klass):
+ 'return issubclass(x, klass) and return False on a TypeError'
+ try:
+ return issubclass(x, klass)
+ except TypeError:
+ return False
+
class MemoryMonitor:
def __init__(self, nmax=20000):
self._nmax = nmax
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py 2008-07-03 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2008-07-03 14:30:13 UTC (rev 5709)
@@ -363,6 +363,12 @@
'b is a boolean. Set draw frame to b'
self._drawFrame = b
+ def get_children(self):
+ children = []
+ children.extend(self.legendHandles)
+ children.extend(self.texts)
+ return children
+
def get_frame(self):
'return the Rectangle instance used to frame the legend'
return self.legendPatch
Modified: trunk/matplotlib/lib/matplotlib/pylab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pylab.py 2008-07-03 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/pylab.py 2008-07-03 14:30:13 UTC (rev 5709)
@@ -38,6 +38,7 @@
figtext - add text in figure coords
figure - create or change active figure
fill - make filled polygons
+ findobj - recursively find all objects matching some criteria
gca - return the current axes
gcf - return the current figure
gci - get the current image, or None
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2008-07-03 13:38:52 UTC (rev 5708)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2008-07-03 14:30:13 UTC (rev 5709)
@@ -38,6 +38,29 @@
from matplotlib.backends import pylab_setup
new_figure_manager, draw_if_interactive, show = pylab_setup()
+
+
+def findobj(o=None, match=None):
+ """
+ recursively find all :class:matplotlib.artist.Artist instances
+ contained in artist instance *p*. if *o* is None, use
+ current figure
+
+ *match* can be
+
+ - None: return all objects contained in artist (including artist)
+
+ - function with signature ``boolean = match(artist)`` used to filter matches
+
+ - class instance: eg Line2D. Only return artists of class type
+
+ """
+
+ if o is None:
+ o = gcf()
+ return o.findobj(match)
+
+
def switch_backend(newbackend):
"""
Switch the default backend to newbackend. This feature is
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-07-03 13:38:59
|
Revision: 5708
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5708&view=rev
Author: jdh2358
Date: 2008-07-03 06:38:52 -0700 (Thu, 03 Jul 2008)
Log Message:
-----------
fixed text picking
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/text.py
Added Paths:
-----------
trunk/matplotlib/examples/api/line_with_text.py
Added: trunk/matplotlib/examples/api/line_with_text.py
===================================================================
--- trunk/matplotlib/examples/api/line_with_text.py (rev 0)
+++ trunk/matplotlib/examples/api/line_with_text.py 2008-07-03 13:38:52 UTC (rev 5708)
@@ -0,0 +1,65 @@
+"""
+Show how to override basic methods so an artist can contain another
+artist. In this case, the line contains a Text instance to label it.
+"""
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.lines as lines
+import matplotlib.transforms as mtransforms
+import matplotlib.text as mtext
+
+
+class MyLine(lines.Line2D):
+
+ def __init__(self, *args, **kwargs):
+ # we'll update the position when the line data is set
+ self.text = mtext.Text(0, 0, '')
+ lines.Line2D.__init__(self, *args, **kwargs)
+
+ # we can't access the label attr until *after* the line is
+ # inited
+ self.text.set_text(self.get_label())
+
+ def set_figure(self, figure):
+ self.text.set_figure(figure)
+ lines.Line2D.set_figure(self, figure)
+
+ def set_axes(self, axes):
+ self.text.set_axes(axes)
+ lines.Line2D.set_axes(self, axes)
+
+ def set_transform(self, transform):
+ # 2 pixel offset
+ texttrans = transform + mtransforms.Affine2D().translate(2, 2)
+ self.text.set_transform(texttrans)
+ lines.Line2D.set_transform(self, transform)
+
+
+ def set_data(self, x, y):
+ if len(x):
+ self.text.set_position((x[-1], y[-1]))
+
+ lines.Line2D.set_data(self, x, y)
+
+ def draw(self, renderer):
+ # draw my label at the end of the line with 2 pixel offset
+ lines.Line2D.draw(self, renderer)
+ self.text.draw(renderer)
+
+
+
+
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+x, y = np.random.rand(2, 20)
+line = MyLine(x, y, mfc='red', ms=12, label='line label')
+#line.text.set_text('line label')
+line.text.set_color('red')
+line.text.set_fontsize(16)
+
+
+ax.add_line(line)
+
+
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py 2008-07-03 13:21:54 UTC (rev 5707)
+++ trunk/matplotlib/lib/matplotlib/text.py 2008-07-03 13:38:52 UTC (rev 5708)
@@ -135,17 +135,15 @@
"""
if callable(self._contains): return self._contains(self,mouseevent)
- try:
- l,b,w,h = self.get_window_extent().get_bounds()
- except:
- # TODO: why does this error occur
- #print str(self),"error looking at get_window_extent"
- return False,{}
+
+ l,b,w,h = self.get_window_extent().bounds
+
r = l+w
t = b+h
xyverts = (l,b), (l, t), (r, t), (r, b)
x, y = mouseevent.x, mouseevent.y
inside = nxutils.pnpoly(x, y, xyverts)
+
return inside,{}
def _get_xy_display(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-07-03 13:22:14
|
Revision: 5707
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5707&view=rev
Author: jdh2358
Date: 2008-07-03 06:21:54 -0700 (Thu, 03 Jul 2008)
Log Message:
-----------
axes was not calling artist set_axes method in set artist props
Modified Paths:
--------------
trunk/matplotlib/examples/widgets/menu.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/pyplot.py
trunk/matplotlib/src/_backend_agg.cpp
trunk/matplotlib/src/_backend_agg.h
trunk/matplotlib/unit/memleak_hawaii3.py
Modified: trunk/matplotlib/examples/widgets/menu.py
===================================================================
--- trunk/matplotlib/examples/widgets/menu.py 2008-07-02 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/examples/widgets/menu.py 2008-07-03 13:21:54 UTC (rev 5707)
@@ -1,45 +1,76 @@
import numpy as np
import matplotlib
+import matplotlib.colors as colors
import matplotlib.patches as patches
import matplotlib.mathtext as mathtext
import matplotlib.pyplot as plt
import matplotlib.artist as artist
import matplotlib.image as image
-matplotlib.rc('image', origin='upper')
+class ItemProperties:
+ def __init__(self, fontsize=14, labelcolor='black', bgcolor='yellow', alpha=1.0):
+ self.fontsize = fontsize
+ self.labelcolor = labelcolor
+ self.bgcolor = bgcolor
+ self.alpha = alpha
+
+ self.labelcolor_rgb = colors.colorConverter.to_rgb(labelcolor)
+ self.bgcolor_rgb = colors.colorConverter.to_rgb(bgcolor)
+
class MenuItem(artist.Artist):
parser = mathtext.MathTextParser("Bitmap")
padx = 5
pady =5
- def __init__(self, fig, labelstr):
+ def __init__(self, fig, labelstr, props=None, hoverprops=None, on_select=None):
artist.Artist.__init__(self)
+
self.set_figure(fig)
+ self.labelstr = labelstr
+ if props is None:
+ props = ItemProperties()
- x, self.depth = self.parser.to_rgba(
- labelstr, color='black', fontsize=14, dpi=100)
- xHover, depth = self.parser.to_rgba(
- labelstr, color='white', fontsize=14, dpi=100)
+ if hoverprops is None:
+ hoverprops = ItemProperties()
+ self.props = props
+ self.hoverprops = hoverprops
+
+ self.on_select = on_select
+
+ x, self.depth = self.parser.to_mask(
+ labelstr, fontsize=props.fontsize, dpi=fig.dpi)
+
+ if props.fontsize!=hoverprops.fontsize:
+ raise NotImplementedError('support for different font sizes not implemented')
+
+
self.labelwidth = x.shape[1]
self.labelheight = x.shape[0]
- print 'h', self.labelheight
- self.label = image.FigureImage(fig)
- self.label.set_array(x.astype(float)/255.)
- self.labelHover = image.FigureImage(fig)
- self.labelHover.set_array(xHover.astype(float)/255.)
+ self.labelArray = np.zeros((x.shape[0], x.shape[1], 4))
+ self.labelArray[:,:,-1] = x/255.
+ self.label = image.FigureImage(fig, origin='upper')
+ self.label.set_array(self.labelArray)
-
# we'll update these later
- self.rect = patches.Rectangle((0,0), 1,1, facecolor='yellow', alpha=0.2)
- self.rectHover = patches.Rectangle((0,0), 1,1, facecolor='blue', alpha=0.2)
+ self.rect = patches.Rectangle((0,0), 1,1)
+ self.set_hover_props(False)
+ fig.canvas.mpl_connect('button_release_event', self.check_select)
+ def check_select(self, event):
+ over, junk = self.rect.contains(event)
+ if not over:
+ return
+
+ if self.on_select is not None:
+ self.on_select(self)
+
def set_extent(self, x, y, w, h):
print x, y, w, h
self.rect.set_x(x)
@@ -47,65 +78,64 @@
self.rect.set_width(w)
self.rect.set_height(h)
- self.rectHover.set_x(x)
- self.rectHover.set_y(y)
- self.rectHover.set_width(w)
- self.rectHover.set_height(h)
-
self.label.ox = x+self.padx
self.label.oy = y-self.depth+self.pady/2.
self.rect._update_patch_transform()
- self.rectHover._update_patch_transform()
- self.labelHover.ox = x+self.padx
- self.labelHover.oy = y-self.depth+self.pady/2.
self.hover = False
- self.activeRect = self.rect
- self.activeLabel = self.label
-
def draw(self, renderer):
- self.activeRect.draw(renderer)
- self.activeLabel.draw(renderer)
+ self.rect.draw(renderer)
+ self.label.draw(renderer)
+ def set_hover_props(self, b):
+ if b:
+ props = self.hoverprops
+ else:
+ props = self.props
+
+ r, g, b = props.labelcolor_rgb
+ self.labelArray[:,:,0] = r
+ self.labelArray[:,:,1] = g
+ self.labelArray[:,:,2] = b
+ self.label.set_array(self.labelArray)
+ self.rect.set(facecolor=props.bgcolor, alpha=props.alpha)
+
def set_hover(self, event):
'check the hover status of event and return true if status is changed'
b,junk = self.rect.contains(event)
- if b:
- self.activeRect = self.rectHover
- self.activeLabel = self.labelHover
- else:
- self.activeRect = self.rect
- self.activeLabel = self.label
- h = self.hover
+ changed = (b != self.hover)
+
+ if changed:
+ self.set_hover_props(b)
+
+
self.hover = b
- return b!=h
+ return changed
class Menu:
- def __init__(self, fig, labels):
+ def __init__(self, fig, menuitems):
self.figure = fig
fig.suppressComposite = True
- menuitems = []
- self.numitems = len(labels)
- for label in labels:
- menuitems.append(MenuItem(fig, label))
self.menuitems = menuitems
+ self.numitems = len(menuitems)
-
maxw = max([item.labelwidth for item in menuitems])
maxh = max([item.labelheight for item in menuitems])
totalh = self.numitems*maxh + (self.numitems+1)*2*MenuItem.pady
+
x0 = 100
y0 = 400
width = maxw + 2*MenuItem.padx
height = maxh+MenuItem.pady
+
for item in menuitems:
left = x0
bottom = y0-maxh-MenuItem.pady
@@ -122,17 +152,27 @@
def on_move(self, event):
draw = False
for item in self.menuitems:
- b = item.set_hover(event)
- draw = b
+ draw = item.set_hover(event)
+ if draw:
+ self.figure.canvas.draw()
+ break
- if draw:
- print 'draw'
- self.figure.canvas.draw()
-
fig = plt.figure()
-menu = Menu(fig, ('open', 'close', 'save', 'save as', 'quit'))
+fig.subplots_adjust(left=0.3)
+props = ItemProperties(labelcolor='black', bgcolor='yellow',
+ fontsize=15, alpha=0.2)
+hoverprops = ItemProperties(labelcolor='white', bgcolor='blue',
+ fontsize=15, alpha=0.2)
+menuitems = []
+for label in ('open', 'close', 'save', 'save as', 'quit'):
+ def on_select(item):
+ print 'you selected', item.labelstr
+ item = MenuItem(fig, label, props=props, hoverprops=hoverprops, on_select=on_select)
+ menuitems.append(item)
+
+menu = Menu(fig, menuitems)
plt.show()
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-07-02 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-07-03 13:21:54 UTC (rev 5707)
@@ -813,8 +813,9 @@
a.set_figure(self.figure)
if not a.is_transform_set():
a.set_transform(self.transData)
- a.axes = self
+ a.set_axes(self)
+
def _gen_axes_patch(self):
"""
Returns the patch used to draw the background of the axes. It
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2008-07-02 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2008-07-03 13:21:54 UTC (rev 5707)
@@ -202,6 +202,14 @@
frameon=frameon,
FigureClass=FigureClass,
**kwargs)
+
+ # make this figure current on button press event
+ def make_active(event):
+ _pylab_helpers.Gcf.set_active(figManager)
+
+ cid = figManager.canvas.mpl_connect('button_press_event', make_active)
+ figManager._cidgcf = cid
+
_pylab_helpers.Gcf.set_active(figManager)
figManager.canvas.figure.number = num
@@ -252,17 +260,21 @@
if len(args)==0:
figManager = _pylab_helpers.Gcf.get_active()
if figManager is None: return
- else: _pylab_helpers.Gcf.destroy(figManager.num)
+ else:
+ figManager.canvas.mpl_disconnect(figManager._cidgcf)
+ _pylab_helpers.Gcf.destroy(figManager.num)
elif len(args)==1:
arg = args[0]
if arg=='all':
for manager in _pylab_helpers.Gcf.get_all_fig_managers():
+ manager.canvas.mpl_disconnect(manager._cidgcf)
_pylab_helpers.Gcf.destroy(manager.num)
elif isinstance(arg, int):
_pylab_helpers.Gcf.destroy(arg)
elif isinstance(arg, Figure):
for manager in _pylab_helpers.Gcf.get_all_fig_managers():
if manager.canvas.figure==arg:
+ manager.canvas.mpl_disconnect(manager._cidgcf)
_pylab_helpers.Gcf.destroy(manager.num)
else:
raise TypeError('Unrecognized argument type %s to close'%type(arg))
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-07-02 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-07-03 13:21:54 UTC (rev 5707)
@@ -90,6 +90,20 @@
return Py::String(PyString_FromStringAndSize((const char*)data, height*stride), true);
}
+Py::Object BufferRegion::set_x(const Py::Tuple &args) {
+ args.verify_length(1);
+ size_t x = Py::Int( args[0] );
+ rect.x1 = x;
+ return Py::Object();
+}
+
+Py::Object BufferRegion::set_y(const Py::Tuple &args) {
+ args.verify_length(1);
+ size_t y = Py::Int( args[0] );
+ rect.y1 = y;
+ return Py::Object();
+}
+
Py::Object BufferRegion::to_string_argb(const Py::Tuple &args) {
// owned=true to prevent memory leak
Py_ssize_t length;
@@ -1608,6 +1622,13 @@
behaviors().name("BufferRegion");
behaviors().doc("A wrapper to pass agg buffer objects to and from the python level");
+
+ add_varargs_method("set_x", &BufferRegion::set_x,
+ "set_x(x)");
+
+ add_varargs_method("set_y", &BufferRegion::set_y,
+ "set_y(y)");
+
add_varargs_method("to_string", &BufferRegion::to_string,
"to_string()");
add_varargs_method("to_string_argb", &BufferRegion::to_string_argb,
Modified: trunk/matplotlib/src/_backend_agg.h
===================================================================
--- trunk/matplotlib/src/_backend_agg.h 2008-07-02 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/src/_backend_agg.h 2008-07-03 13:21:54 UTC (rev 5707)
@@ -102,6 +102,10 @@
bool freemem;
+ // set the x and y corners of the rectangle
+ Py::Object set_x(const Py::Tuple &args);
+ Py::Object set_y(const Py::Tuple &args);
+
Py::Object to_string(const Py::Tuple &args);
Py::Object to_string_argb(const Py::Tuple &args);
static void init_type(void);
Modified: trunk/matplotlib/unit/memleak_hawaii3.py
===================================================================
--- trunk/matplotlib/unit/memleak_hawaii3.py 2008-07-02 15:36:38 UTC (rev 5706)
+++ trunk/matplotlib/unit/memleak_hawaii3.py 2008-07-03 13:21:54 UTC (rev 5707)
@@ -2,15 +2,15 @@
import os, sys, time, gc
import matplotlib
-matplotlib.use('Agg')
+matplotlib.use('PDF')
from matplotlib.cbook import report_memory
-import matplotlib.numerix as nx
+import numpy as np
from pylab import figure, show, close
# take a memory snapshot on indStart and compare it with indEnd
-rand = nx.mlab.rand
+rand = np.mlab.rand
indStart, indEnd = 200, 401
for i in range(indEnd):
@@ -19,8 +19,8 @@
fig.clf()
- t1 = nx.arange(0.0, 2.0, 0.01)
- y1 = nx.sin(2*nx.pi*t1)
+ t1 = np.arange(0.0, 2.0, 0.01)
+ y1 = np.sin(2*np.pi*t1)
y2 = rand(len(t1))
X = rand(50,50)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-07-02 15:36:45
|
Revision: 5706
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5706&view=rev
Author: mdboom
Date: 2008-07-02 08:36:38 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
Fix bug using autolegend with LineCollection.
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/legend.py
Modified: branches/v0_91_maint/lib/matplotlib/legend.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/legend.py 2008-07-02 11:08:22 UTC (rev 5705)
+++ branches/v0_91_maint/lib/matplotlib/legend.py 2008-07-02 15:36:38 UTC (rev 5706)
@@ -375,11 +375,11 @@
for handle in ax.collections:
if isinstance(handle, LineCollection):
- hlines = handle.get_lines()
+ hlines = handle._segments
trans = handle.get_transform()
for line in hlines:
tline = trans.seq_xy_tups(line)
- aline = [inv(v) for v in tline]
+ aline = [inv(tuple(v)) for v in tline]
lines.append(aline)
return [vertices, bboxes, lines]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-07-02 11:08:51
|
Revision: 5705
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5705&view=rev
Author: jdh2358
Date: 2008-07-02 04:08:22 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
cleaned legend demo example
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/hexbin_demo.py
trunk/matplotlib/examples/pylab_examples/legend_demo.py
trunk/matplotlib/lib/matplotlib/axes.py
Added Paths:
-----------
trunk/matplotlib/examples/api/legend_demo.py
Added: trunk/matplotlib/examples/api/legend_demo.py
===================================================================
--- trunk/matplotlib/examples/api/legend_demo.py (rev 0)
+++ trunk/matplotlib/examples/api/legend_demo.py 2008-07-02 11:08:22 UTC (rev 5705)
@@ -0,0 +1,41 @@
+import numpy as np
+import matplotlib.pyplot as plt
+
+a = np.arange(0,3,.02)
+b = np.arange(0,3,.02)
+c = np.exp(a)
+d = c[::-1]
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.plot(a,c,'k--',a,d,'k:',a,c+d,'k')
+leg = ax.legend(('Model length', 'Data length', 'Total message length'),
+ 'upper center', shadow=True)
+ax.set_ylim([-1,20])
+ax.grid(False)
+ax.set_xlabel('Model complexity --->')
+ax.set_ylabel('Message length --->')
+ax.set_title('Minimum Message Length')
+
+ax.set_yticklabels([])
+ax.set_xticklabels([])
+
+# set some legend properties. All the code below is optional. The
+# defaults are usually sensible but if you need more control, this
+# shows you how
+
+# the matplotlib.patches.Rectangle instance surrounding the legend
+frame = leg.get_frame()
+frame.set_facecolor('0.80') # set the frame face color to light gray
+
+# matplotlib.text.Text instances
+for t in leg.get_texts():
+ t.set_fontsize('small') # the legend text fontsize
+
+# matplotlib.lines.Line2D instances
+for l in leg.get_lines():
+ l.set_linewidth(1.5) # the legend line width
+plt.show()
+
+
+
Modified: trunk/matplotlib/examples/pylab_examples/hexbin_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/hexbin_demo.py 2008-07-01 12:01:38 UTC (rev 5704)
+++ trunk/matplotlib/examples/pylab_examples/hexbin_demo.py 2008-07-02 11:08:22 UTC (rev 5705)
@@ -6,7 +6,9 @@
"""
import numpy as np
+import matplotlib.cm as cm
import matplotlib.pyplot as plt
+
n = 100000
x = np.random.standard_normal(n)
y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)
@@ -17,14 +19,14 @@
plt.subplots_adjust(hspace=0.5)
plt.subplot(121)
-plt.hexbin(x,y)
+plt.hexbin(x,y, cmap=cm.jet)
plt.axis([xmin, xmax, ymin, ymax])
plt.title("Hexagon binning")
cb = plt.colorbar()
cb.set_label('counts')
plt.subplot(122)
-plt.hexbin(x,y,bins='log')
+plt.hexbin(x,y,bins='log', cmap=cm.jet)
plt.axis([xmin, xmax, ymin, ymax])
plt.title("With a log color scale")
cb = plt.colorbar()
Modified: trunk/matplotlib/examples/pylab_examples/legend_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/legend_demo.py 2008-07-01 12:01:38 UTC (rev 5704)
+++ trunk/matplotlib/examples/pylab_examples/legend_demo.py 2008-07-02 11:08:22 UTC (rev 5705)
@@ -4,32 +4,31 @@
#See http://matplotlib.sf.net/examples/legend_demo2.py for an example
#controlling which lines the legend uses and the order
+import numpy as np
+import matplotlib.pyplot as plt
-from pylab import *
+a = np.arange(0,3,.02)
+b = np.arange(0,3,.02)
+c = np.exp(a)
+d = c[::-1]
-a = arange(0,3,.02)
-b = arange(0,3,.02)
-c=exp(a)
-d=c.tolist()
-d.reverse()
-d = array(d)
+ax = plt.subplot(111)
+plt.plot(a,c,'k--',a,d,'k:',a,c+d,'k')
+plt.legend(('Model length', 'Data length', 'Total message length'),
+ 'upper center', shadow=True)
+plt.ylim([-1,20])
+plt.grid(False)
+plt.xlabel('Model complexity --->')
+plt.ylabel('Message length --->')
+plt.title('Minimum Message Length')
-ax = subplot(111)
-plot(a,c,'k--',a,d,'k:',a,c+d,'k')
-legend(('Model length', 'Data length', 'Total message length'),
- 'upper center', shadow=True)
-ax.set_ylim([-1,20])
-ax.grid(0)
-xlabel('Model complexity --->')
-ylabel('Message length --->')
-title('Minimum Message Length')
-setp(gca(), 'yticklabels', [])
-setp(gca(), 'xticklabels', [])
+plt.setp(plt.gca(), 'yticklabels', [])
+plt.setp(plt.gca(), 'xticklabels', [])
# set some legend properties. All the code below is optional. The
# defaults are usually sensible but if you need more control, this
# shows you how
-leg = gca().get_legend()
+leg = plt.gca().get_legend()
ltext = leg.get_texts() # all the text.Text instance in the legend
llines = leg.get_lines() # all the lines.Line2D instance in the legend
frame = leg.get_frame() # the patch.Rectangle instance surrounding the legend
@@ -37,11 +36,11 @@
# see text.Text, lines.Line2D, and patches.Rectangle for more info on
# the settable properties of lines, text, and rectangles
frame.set_facecolor('0.80') # set the frame face color to light gray
-setp(ltext, fontsize='small') # the legend text fontsize
-setp(llines, linewidth=1.5) # the legend linewidth
+plt.setp(ltext, fontsize='small') # the legend text fontsize
+plt.setp(llines, linewidth=1.5) # the legend linewidth
#leg.draw_frame(False) # don't draw the legend frame
-#savefig('legend_demo')
-show()
+#plt.savefig('legend_demo')
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-07-01 12:01:38 UTC (rev 5704)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-07-02 11:08:22 UTC (rev 5705)
@@ -3592,7 +3592,7 @@
**Example:**
- .. plot:: legend_demo.py
+ .. plot:: ../mpl_examples/api/legend_demo.py
"""
def get_handles():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-07-01 12:01:42
|
Revision: 5704
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5704&view=rev
Author: mdboom
Date: 2008-07-01 05:01:38 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
Remove autolayout.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template
Modified: trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template
===================================================================
--- trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template 2008-07-01 12:01:27 UTC (rev 5703)
+++ trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template 2008-07-01 12:01:38 UTC (rev 5704)
@@ -3,32 +3,32 @@
# This is a sample matplotlib configuration file. It should be placed
# in HOME/.matplotlib (unix/linux like systems) and
# C:\Documents and Settings\yourname\.matplotlib (win32 systems)
-#
+#
# By default, the installer will overwrite the existing file in the install
# path, so if you want to preserve yours, please move it to your HOME dir and
# set the environment variable if necessary.
-#
+#
# This file is best viewed in a editor which supports ini or conf mode syntax
# highlighting.
-#
+#
# Blank lines, or lines starting with a comment symbol, are ignored,
# as are trailing comments. Other lines must have the format
-#
+#
# key = val optional comment
-#
+#
# val should be valid python syntax, just as you would use when setting
# properties using rcParams. This should become more obvious by inspecting
# the default values listed herein.
-#
+#
# Colors: for the color values below, you can either use
# - a matplotlib color string, such as r | k | b
# - an rgb tuple, such as (1.0, 0.5, 0.0)
# - a hex string, such as #ff00ff or ff00ff
# - a scalar grayscale intensity such as 0.75
# - a legal html color name, eg red | blue | darkslategray
-#
+#
# Interactivity: see http://matplotlib.sourceforge.net/interactive.html.
-#
+#
# ### CONFIGURATION BEGINS HERE ###
# a value of type 'str'
@@ -42,7 +42,7 @@
# 'Africa/Abidjan' or 'Africa/Accra' or 'Africa/Addis_Ababa' or
# 'Africa/Algiers' or 'Africa/Asmara' or 'Africa/Asmera' or 'Africa/Bamako' or
# 'Africa/Bangui' or 'Africa/Banjul' or 'Africa/Bissau' or 'Africa/Blantyre'
-# <...snipped 156 lines...>
+# <...snipped 156 lines...>
# 'US/Michigan' or 'US/Mountain' or 'US/Pacific' or 'US/Pacific-New' or
# 'US/Samoa' or 'UTC' or 'Universal' or 'W-SU' or 'WET' or 'Zulu' or
# 'posixrules'
@@ -145,8 +145,6 @@
negative_linestyle = 'dashed'
[figure]
- # a boolean
- autolayout = False
# a float
dpi = 80
# any valid matplotlib color, eg an abbreviation like 'r' for red, a full
@@ -219,7 +217,7 @@
# 'Accent' or 'Accent_r' or 'Blues' or 'Blues_r' or 'BrBG' or 'BrBG_r' or
# 'BuGn' or 'BuGn_r' or 'BuPu' or 'BuPu_r' or 'Dark2' or 'Dark2_r' or
# 'GnBu' or 'GnBu_r' or 'Greens' or 'Greens_r' or 'Greys' or 'Greys_r' or
- # <...snipped 16 lines...>
+ # <...snipped 16 lines...>
# 'pink_r' or 'prism' or 'prism_r' or 'spectral' or 'spectral_r' or
# 'spring' or 'spring_r' or 'summer' or 'summer_r' or 'winter' or
# 'winter_r'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-07-01 12:01:29
|
Revision: 5703
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5703&view=rev
Author: mdboom
Date: 2008-07-01 05:01:27 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
docstring fixes.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/path.py
Modified: trunk/matplotlib/lib/matplotlib/path.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/path.py 2008-07-01 11:59:22 UTC (rev 5702)
+++ trunk/matplotlib/lib/matplotlib/path.py 2008-07-01 12:01:27 UTC (rev 5703)
@@ -24,7 +24,7 @@
These two arrays always have the same length in the first
dimension. For example, to represent a cubic curve, you must
- provide three vertices as well as three codes "CURVE3".
+ provide three vertices as well as three codes ``CURVE3``.
The code types are:
@@ -53,8 +53,8 @@
Users of Path objects should not access the vertices and codes
arrays directly. Instead, they should use :meth:`iter_segments`
to get the vertex/code pairs. This is important, since many
- :class:`Path`s, as an optimization, do not store a codes array at
- all, but have a default one provided for them by
+ :class:`Path` objects, as an optimization, do not store a *codes*
+ at all, but have a default one provided for them by
:meth:`iter_segments`.
"""
@@ -168,16 +168,16 @@
if not len(vertices):
return
- codes = self.codes
+ codes = self.codes
len_vertices = len(vertices)
- isnan = np.isnan
- any = np.any
+ isnan = np.isnan
+ any = np.any
NUM_VERTICES = self.NUM_VERTICES
- MOVETO = self.MOVETO
- LINETO = self.LINETO
- CLOSEPOLY = self.CLOSEPOLY
- STOP = self.STOP
+ MOVETO = self.MOVETO
+ LINETO = self.LINETO
+ CLOSEPOLY = self.CLOSEPOLY
+ STOP = self.STOP
if codes is None:
next_code = MOVETO
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-07-01 11:59:25
|
Revision: 5702
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5702&view=rev
Author: mdboom
Date: 2008-07-01 04:59:22 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
Don't error on figure.autolayout -- just warn that it does nothing.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/config/rcsetup.py
trunk/matplotlib/lib/matplotlib/rcsetup.py
Modified: trunk/matplotlib/lib/matplotlib/config/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2008-06-30 23:14:42 UTC (rev 5701)
+++ trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2008-07-01 11:59:22 UTC (rev 5702)
@@ -83,6 +83,10 @@
'None','classic','toolbar2',
], ignorecase=True)
+def validate_autolayout(v):
+ if v:
+ warnings.warn("figure.autolayout is not currently supported")
+
class validate_nseq_float:
def __init__(self, n):
self.n = n
@@ -439,6 +443,7 @@
'figure.dpi' : [80, validate_float], # DPI
'figure.facecolor' : ['0.75', validate_color], # facecolor; scalar gray
'figure.edgecolor' : ['w', validate_color], # edgecolor; white
+ 'figure.autolayout' : [False, validate_autolayout],
'figure.subplot.left' : [0.125, ValidateInterval(0, 1, closedmin=False, closedmax=False)],
'figure.subplot.right' : [0.9, ValidateInterval(0, 1, closedmin=False, closedmax=False)],
Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-06-30 23:14:42 UTC (rev 5701)
+++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-07-01 11:59:22 UTC (rev 5702)
@@ -14,6 +14,7 @@
"""
import os
+import warnings
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
from matplotlib.colors import is_color_like
@@ -109,6 +110,10 @@
'None','classic','toolbar2',
], ignorecase=True)
+def validate_autolayout(v):
+ if v:
+ warnings.warn("figure.autolayout is not currently supported")
+
class validate_nseq_float:
def __init__(self, n):
self.n = n
@@ -449,6 +454,7 @@
'figure.dpi' : [ 80, validate_float], # DPI
'figure.facecolor' : [ '0.75', validate_color], # facecolor; scalar gray
'figure.edgecolor' : [ 'w', validate_color], # edgecolor; white
+ 'figure.autolayout' : [ False, validate_autolayout],
'figure.subplot.left' : [0.125, ValidateInterval(0, 1, closedmin=True, closedmax=True)],
'figure.subplot.right' : [0.9, ValidateInterval(0, 1, closedmin=True, closedmax=True)],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-06-30 23:14:47
|
Revision: 5701
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5701&view=rev
Author: dsdale
Date: 2008-06-30 16:14:42 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
another attempt to fix TextWithDash
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/text.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-30 13:24:13 UTC (rev 5700)
+++ trunk/matplotlib/CHANGELOG 2008-06-30 23:14:42 UTC (rev 5701)
@@ -1,3 +1,5 @@
+2008-06-30 Another attempt to fix TextWithDash - DSD
+
2008-06-30 Removed Qt4 NavigationToolbar2.destroy -- it appears to
have been unnecessary and caused a bug reported by P.
Raybaut - DSD
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py 2008-06-30 13:24:13 UTC (rev 5700)
+++ trunk/matplotlib/lib/matplotlib/text.py 2008-06-30 23:14:42 UTC (rev 5701)
@@ -298,7 +298,12 @@
bbox, info = self._get_layout(renderer)
trans = self.get_transform()
- posx, posy = self.get_position()
+
+ # don't use self.get_position here, which refers to text position
+ # in Text, and dash position in TextWithDash:
+ posx = float(self.convert_xunits(self._x))
+ posy = float(self.convert_yunits(self._y))
+
posx, posy = trans.transform_point((posx, posy))
canvasw, canvash = renderer.get_canvas_width_height()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-06-30 13:24:26
|
Revision: 5700
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5700&view=rev
Author: dsdale
Date: 2008-06-30 06:24:13 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
removed Qt4's NavigationToolbar2.destroy method
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-06-30 13:21:19 UTC (rev 5699)
+++ branches/v0_91_maint/CHANGELOG 2008-06-30 13:24:13 UTC (rev 5700)
@@ -1,3 +1,7 @@
+2008-06-30 Removed Qt4 NavigationToolbar2.destroy -- it appears to
+ have been unnecessary and caused a bug reported by P.
+ Raybaut - DSD
+
2008-06-26 Fix mathtext bug for expressions like $x_{\leftarrow}$ - MGD
2008-06-26 Fix direction of horizontal/vertical hatches - MGD
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py 2008-06-30 13:21:19 UTC (rev 5699)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py 2008-06-30 13:24:13 UTC (rev 5700)
@@ -340,13 +340,6 @@
# reference holder for subplots_adjust window
self.adj_window = None
- def destroy( self ):
- for text, tooltip_text, image_file, callback in self.toolitems:
- if text is not None:
- QtCore.QObject.disconnect( self.buttons[ text ],
- QtCore.SIGNAL( 'clicked()' ),
- getattr( self, callback ) )
-
def dynamic_update( self ):
self.canvas.draw()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-06-30 13:21:30
|
Revision: 5699
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5699&view=rev
Author: dsdale
Date: 2008-06-30 06:21:19 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
removed Qt4's NavigationToolbar2.destroy method
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-30 12:13:55 UTC (rev 5698)
+++ trunk/matplotlib/CHANGELOG 2008-06-30 13:21:19 UTC (rev 5699)
@@ -1,3 +1,7 @@
+2008-06-30 Removed Qt4 NavigationToolbar2.destroy -- it appears to
+ have been unnecessary and caused a bug reported by P.
+ Raybaut - DSD
+
2008-06-27 Fixed tick positioning bug - MM
2008-06-27 Fix dashed text bug where text was at the wrong end of the
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-06-30 12:13:55 UTC (rev 5698)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-06-30 13:21:19 UTC (rev 5699)
@@ -311,13 +311,6 @@
# reference holder for subplots_adjust window
self.adj_window = None
- def destroy( self ):
- for text, tooltip_text, image_file, callback in self.toolitems:
- if text is not None:
- QtCore.QObject.disconnect( self.buttons[ text ],
- QtCore.SIGNAL( 'clicked()' ),
- getattr( self, callback ) )
-
def dynamic_update( self ):
self.canvas.draw()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-06-30 12:13:59
|
Revision: 5698
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5698&view=rev
Author: mdboom
Date: 2008-06-30 05:13:55 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
Fixed inverse of natural log bug. (Thanks, Ryan May)
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/scale.py
Modified: trunk/matplotlib/lib/matplotlib/scale.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/scale.py 2008-06-28 13:50:45 UTC (rev 5697)
+++ trunk/matplotlib/lib/matplotlib/scale.py 2008-06-30 12:13:55 UTC (rev 5698)
@@ -134,7 +134,7 @@
return ma.power(np.e, a) / np.e
def inverted(self):
- return LogScale.Log2Transform()
+ return LogScale.NaturalLogTransform()
class LogTransform(Transform):
input_dims = 1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-28 13:50:51
|
Revision: 5697
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5697&view=rev
Author: jdh2358
Date: 2008-06-28 06:50:45 -0700 (Sat, 28 Jun 2008)
Log Message:
-----------
reverting text with dash fixes; see post on mailing list
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/text.py
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py 2008-06-28 01:10:58 UTC (rev 5696)
+++ trunk/matplotlib/lib/matplotlib/text.py 2008-06-28 13:50:45 UTC (rev 5697)
@@ -745,8 +745,8 @@
def get_position(self):
"Return x, y as tuple"
- x = float(self.convert_xunits(self._x))
- y = float(self.convert_yunits(self._y))
+ x = float(self.convert_xunits(self._dashx))
+ y = float(self.convert_yunits(self._dashy))
return x, y
def get_prop_tup(self):
@@ -939,8 +939,7 @@
ACCEPTS: float
"""
- self._x = float(x)
- self._dashx = self._x
+ self._dashx = float(x)
def set_y(self, y):
"""
@@ -948,8 +947,7 @@
ACCEPTS: float
"""
- self._y = float(y)
- self._dashy = self._y
+ self._dashy = float(y)
def set_transform(self, t):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-06-28 01:11:00
|
Revision: 5696
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5696&view=rev
Author: mmetz_bn
Date: 2008-06-27 18:10:58 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
Fixed tick positioning bug
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/text.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-27 18:54:51 UTC (rev 5695)
+++ trunk/matplotlib/CHANGELOG 2008-06-28 01:10:58 UTC (rev 5696)
@@ -1,3 +1,5 @@
+2008-06-27 Fixed tick positioning bug - MM
+
2008-06-27 Fix dashed text bug where text was at the wrong end of the
dash - MGD
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py 2008-06-27 18:54:51 UTC (rev 5695)
+++ trunk/matplotlib/lib/matplotlib/text.py 2008-06-28 01:10:58 UTC (rev 5696)
@@ -939,7 +939,8 @@
ACCEPTS: float
"""
- self._dashx = float(x)
+ self._x = float(x)
+ self._dashx = self._x
def set_y(self, y):
"""
@@ -947,7 +948,8 @@
ACCEPTS: float
"""
- self._dashy = float(y)
+ self._y = float(y)
+ self._dashy = self._y
def set_transform(self, t):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-06-27 18:54:53
|
Revision: 5695
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5695&view=rev
Author: mdboom
Date: 2008-06-27 11:54:51 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
Fix Figure.add_axes docstring formatting bugs.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/figure.py
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2008-06-27 18:53:11 UTC (rev 5694)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2008-06-27 18:54:51 UTC (rev 5695)
@@ -636,13 +636,15 @@
def add_axes(self, *args, **kwargs):
"""
- Add an a axes with axes rect [left, bottom, width, height] where all
- quantities are in fractions of figure width and height. kwargs are
- legal Axes kwargs plus "projection" which sets the projection type
- of the axes. (For backward compatibility, *polar=True* may also be
- provided, which is equivalent to *projection='polar'*).
- Valid values for "projection" are: %s. Some of these projections
- support additional kwargs, which may be provided to add_axes::
+ Add an a axes with axes rect [*left*, *bottom*, *width*,
+ *height*] where all quantities are in fractions of figure
+ width and height. kwargs are legal
+ :class:`~matplotlib.axes.Axes` kwargs plus *projection* which
+ sets the projection type of the axes. (For backward
+ compatibility, ``polar=True`` may also be provided, which is
+ equivalent to ``projection='polar'``). Valid values for
+ *projection* are: %s. Some of these projections support
+ additional kwargs, which may be provided to :meth:`add_axes`::
rect = l,b,w,h
fig.add_axes(rect)
@@ -651,13 +653,14 @@
fig.add_axes(rect, projection='polar')
fig.add_axes(ax) # add an Axes instance
- If the figure already has an axes with key *args, *kwargs then it will
- simply make that axes current and return it. If you do not want this
- behavior, eg you want to force the creation of a new axes, you must
- use a unique set of args and kwargs. The artist "label" attribute has
- been exposed for this purpose. Eg, if you want two axes that are
- otherwise identical to be added to the figure, make sure you give them
- unique labels::
+ If the figure already has an axes with the same parameters,
+ then it will simply make that axes current and return it. If
+ you do not want this behavior, eg. you want to force the
+ creation of a new axes, you must use a unique set of args and
+ kwargs. The axes :attr:`~matplotlib.axes.Axes.label`
+ attribute has been exposed for this purpose. Eg., if you want
+ two axes that are otherwise identical to be added to the
+ figure, make sure you give them unique labels::
fig.add_axes(rect, label='axes1')
fig.add_axes(rect, label='axes2')
@@ -665,8 +668,9 @@
The :class:`~matplotlib.axes.Axes` instance will be returned.
The following kwargs are supported:
+
%s
- """ % (", ".join(get_projection_names()), '%(Axes)s')
+ """
key = self._make_key(*args, **kwargs)
@@ -699,6 +703,7 @@
self._seen[key] = a
return a
+ add_axes.__doc__ = add_axes.__doc__ % (", ".join(get_projection_names()), '%(Axes)s')
add_axes.__doc__ = dedent(add_axes.__doc__) % artist.kwdocd
def add_subplot(self, *args, **kwargs):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-06-27 18:53:16
|
Revision: 5694
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5694&view=rev
Author: mdboom
Date: 2008-06-27 11:53:11 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
Fix dashed text bug where text was at the wrong end of the dash (Thanks Andrea Gavana)
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/text.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-06-27 15:42:44 UTC (rev 5693)
+++ trunk/matplotlib/CHANGELOG 2008-06-27 18:53:11 UTC (rev 5694)
@@ -1,3 +1,6 @@
+2008-06-27 Fix dashed text bug where text was at the wrong end of the
+ dash - MGD
+
2008-06-26 Fix mathtext bug for expressions like $x_{\leftarrow}$ - MGD
2008-06-26 Fix direction of horizontal/vertical hatches - MGD
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py 2008-06-27 15:42:44 UTC (rev 5693)
+++ trunk/matplotlib/lib/matplotlib/text.py 2008-06-27 18:53:11 UTC (rev 5694)
@@ -745,8 +745,8 @@
def get_position(self):
"Return x, y as tuple"
- x = float(self.convert_xunits(self._dashx))
- y = float(self.convert_yunits(self._dashy))
+ x = float(self.convert_xunits(self._x))
+ y = float(self.convert_yunits(self._y))
return x, y
def get_prop_tup(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-27 15:55:31
|
Revision: 5689
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5689&view=rev
Author: jdh2358
Date: 2008-06-27 08:33:17 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
fixed errorbar demo
Modified Paths:
--------------
trunk/matplotlib/doc/sphinxext/plot_directive.py
trunk/matplotlib/lib/matplotlib/contour.py
Modified: trunk/matplotlib/doc/sphinxext/plot_directive.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-06-27 15:25:50 UTC (rev 5688)
+++ trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-06-27 15:33:17 UTC (rev 5689)
@@ -43,7 +43,7 @@
template = """
.. htmlonly::
- [`py <../%(srcdir)s/%(basename)s.py>`__,
+ [`source code <../%(srcdir)s/%(basename)s.py>`__,
`png <../%(srcdir)s/%(basename)s.hires.png>`__,
`pdf <../%(srcdir)s/%(basename)s.pdf>`__]
Modified: trunk/matplotlib/lib/matplotlib/contour.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/contour.py 2008-06-27 15:25:50 UTC (rev 5688)
+++ trunk/matplotlib/lib/matplotlib/contour.py 2008-06-27 15:33:17 UTC (rev 5689)
@@ -893,5 +893,7 @@
be removed. Chunking introduces artifacts at the chunk boundaries
unless *antialiased* is *False*.
+ **Example:**
+
.. plot:: contour_demo.py
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-27 15:53:17
|
Revision: 5691
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5691&view=rev
Author: jdh2358
Date: 2008-06-27 08:39:28 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
removing the copied files I accidentally added (sigh). It is confusing to put autogenerated files next to legit files in pyplot...
Removed Paths:
-------------
trunk/matplotlib/doc/pyplots/arrow_demo.py
trunk/matplotlib/doc/pyplots/axhspan_demo.py
trunk/matplotlib/doc/pyplots/bar_stacked.py
trunk/matplotlib/doc/pyplots/broken_barh.py
trunk/matplotlib/doc/pyplots/cohere_demo.py
trunk/matplotlib/doc/pyplots/csd_demo.py
trunk/matplotlib/doc/pyplots/figimage_demo.py
trunk/matplotlib/doc/pyplots/figlegend_demo.py
trunk/matplotlib/doc/pyplots/fill_demo.py
trunk/matplotlib/doc/pyplots/hexbin_demo.py
trunk/matplotlib/doc/pyplots/histogram_demo.py
trunk/matplotlib/doc/pyplots/image_demo.py
trunk/matplotlib/doc/pyplots/log_demo.py
trunk/matplotlib/doc/pyplots/xcorr_demo.py
Deleted: trunk/matplotlib/doc/pyplots/arrow_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/arrow_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/arrow_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,313 +0,0 @@
-#!/usr/bin/env python
-"""Arrow drawing example for the new fancy_arrow facilities.
-
-Code contributed by: Rob Knight <ro...@sp...>
-
-usage:
-
- python arrow_demo.py realistic|full|sample|extreme
-
-
-"""
-from pylab import *
-
-rates_to_bases={'r1':'AT', 'r2':'TA', 'r3':'GA','r4':'AG','r5':'CA','r6':'AC', \
- 'r7':'GT', 'r8':'TG', 'r9':'CT','r10':'TC','r11':'GC','r12':'CG'}
-numbered_bases_to_rates = dict([(v,k) for k, v in rates_to_bases.items()])
-lettered_bases_to_rates = dict([(v, 'r'+v) for k, v in rates_to_bases.items()])
-def add_dicts(d1, d2):
- """Adds two dicts and returns the result."""
- result = d1.copy()
- result.update(d2)
- return result
-
-def make_arrow_plot(data, size=4, display='length', shape='right', \
- max_arrow_width=0.03, arrow_sep = 0.02, alpha=0.5, \
- normalize_data=False, ec=None, labelcolor=None, \
- head_starts_at_zero=True, rate_labels=lettered_bases_to_rates,\
- **kwargs):
- """Makes an arrow plot.
-
- Parameters:
-
- data: dict with probabilities for the bases and pair transitions.
- size: size of the graph in inches.
- display: 'length', 'width', or 'alpha' for arrow property to change.
- shape: 'full', 'left', or 'right' for full or half arrows.
- max_arrow_width: maximum width of an arrow, data coordinates.
- arrow_sep: separation between arrows in a pair, data coordinates.
- alpha: maximum opacity of arrows, default 0.8.
-
- **kwargs can be anything allowed by a Arrow object, e.g.
- linewidth and edgecolor.
- """
-
- xlim(-0.5,1.5)
- ylim(-0.5,1.5)
- gcf().set_size_inches(size,size)
- xticks([])
- yticks([])
- max_text_size = size*12
- min_text_size = size
- label_text_size = size*2.5
- text_params={'ha':'center', 'va':'center', 'family':'sans-serif',\
- 'fontweight':'bold'}
- r2 = sqrt(2)
-
- deltas = {\
- 'AT':(1,0),
- 'TA':(-1,0),
- 'GA':(0,1),
- 'AG':(0,-1),
- 'CA':(-1/r2, 1/r2),
- 'AC':(1/r2, -1/r2),
- 'GT':(1/r2, 1/r2),
- 'TG':(-1/r2,-1/r2),
- 'CT':(0,1),
- 'TC':(0,-1),
- 'GC':(1,0),
- 'CG':(-1,0)
- }
-
- colors = {\
- 'AT':'r',
- 'TA':'k',
- 'GA':'g',
- 'AG':'r',
- 'CA':'b',
- 'AC':'r',
- 'GT':'g',
- 'TG':'k',
- 'CT':'b',
- 'TC':'k',
- 'GC':'g',
- 'CG':'b'
- }
-
- label_positions = {\
- 'AT':'center',
- 'TA':'center',
- 'GA':'center',
- 'AG':'center',
- 'CA':'left',
- 'AC':'left',
- 'GT':'left',
- 'TG':'left',
- 'CT':'center',
- 'TC':'center',
- 'GC':'center',
- 'CG':'center'
- }
-
-
- def do_fontsize(k):
- return float(clip(max_text_size*sqrt(data[k]),\
- min_text_size,max_text_size))
-
- A = text(0,1, '$A_3$', color='r', size=do_fontsize('A'), **text_params)
- T = text(1,1, '$T_3$', color='k', size=do_fontsize('T'), **text_params)
- G = text(0,0, '$G_3$', color='g', size=do_fontsize('G'), **text_params)
- C = text(1,0, '$C_3$', color='b', size=do_fontsize('C'), **text_params)
-
- arrow_h_offset = 0.25 #data coordinates, empirically determined
- max_arrow_length = 1 - 2*arrow_h_offset
-
- max_arrow_width = max_arrow_width
- max_head_width = 2.5*max_arrow_width
- max_head_length = 2*max_arrow_width
- arrow_params={'length_includes_head':True, 'shape':shape, \
- 'head_starts_at_zero':head_starts_at_zero}
- ax = gca()
- sf = 0.6 #max arrow size represents this in data coords
-
- d = (r2/2 + arrow_h_offset - 0.5)/r2 #distance for diags
- r2v = arrow_sep/r2 #offset for diags
-
- #tuple of x, y for start position
- positions = {\
- 'AT': (arrow_h_offset, 1+arrow_sep),
- 'TA': (1-arrow_h_offset, 1-arrow_sep),
- 'GA': (-arrow_sep, arrow_h_offset),
- 'AG': (arrow_sep, 1-arrow_h_offset),
- 'CA': (1-d-r2v, d-r2v),
- 'AC': (d+r2v, 1-d+r2v),
- 'GT': (d-r2v, d+r2v),
- 'TG': (1-d+r2v, 1-d-r2v),
- 'CT': (1-arrow_sep, arrow_h_offset),
- 'TC': (1+arrow_sep, 1-arrow_h_offset),
- 'GC': (arrow_h_offset, arrow_sep),
- 'CG': (1-arrow_h_offset, -arrow_sep),
- }
-
- if normalize_data:
- #find maximum value for rates, i.e. where keys are 2 chars long
- max_val = 0
- for k, v in data.items():
- if len(k) == 2:
- max_val = max(max_val, v)
- #divide rates by max val, multiply by arrow scale factor
- for k, v in data.items():
- data[k] = v/max_val*sf
-
- def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor):
- #set the length of the arrow
- if display == 'length':
- length = max_head_length+(max_arrow_length-max_head_length)*\
- data[pair]/sf
- else:
- length = max_arrow_length
- #set the transparency of the arrow
- if display == 'alph':
- alpha = min(data[pair]/sf, alpha)
- else:
- alpha=alpha
- #set the width of the arrow
- if display == 'width':
- scale = data[pair]/sf
- width = max_arrow_width*scale
- head_width = max_head_width*scale
- head_length = max_head_length*scale
- else:
- width = max_arrow_width
- head_width = max_head_width
- head_length = max_head_length
-
- fc = colors[pair]
- ec = ec or fc
-
- x_scale, y_scale = deltas[pair]
- x_pos, y_pos = positions[pair]
- arrow(x_pos, y_pos, x_scale*length, y_scale*length, \
- fc=fc, ec=ec, alpha=alpha, width=width, head_width=head_width, \
- head_length=head_length, **arrow_params)
-
- #figure out coordinates for text
- #if drawing relative to base: x and y are same as for arrow
- #dx and dy are one arrow width left and up
- #need to rotate based on direction of arrow, use x_scale and y_scale
- #as sin x and cos x?
- sx, cx = y_scale, x_scale
-
- where = label_positions[pair]
- if where == 'left':
- orig_position = 3*array([[max_arrow_width, max_arrow_width]])
- elif where == 'absolute':
- orig_position = array([[max_arrow_length/2.0, 3*max_arrow_width]])
- elif where == 'right':
- orig_position = array([[length-3*max_arrow_width,\
- 3*max_arrow_width]])
- elif where == 'center':
- orig_position = array([[length/2.0, 3*max_arrow_width]])
- else:
- raise ValueError, "Got unknown position parameter %s" % where
-
-
-
- M = array([[cx, sx],[-sx,cx]])
- coords = dot(orig_position, M) + [[x_pos, y_pos]]
- x, y = ravel(coords)
- orig_label = rate_labels[pair]
- label = '$%s_{_{\mathrm{%s}}}$' % (orig_label[0], orig_label[1:])
-
- text(x, y, label, size=label_text_size, ha='center', va='center', \
- color=labelcolor or fc)
-
- for p in positions.keys():
- draw_arrow(p)
-
- #test data
-all_on_max = dict([(i, 1) for i in 'TCAG'] + \
- [(i+j, 0.6) for i in 'TCAG' for j in 'TCAG'])
-
-realistic_data = {
- 'A':0.4,
- 'T':0.3,
- 'G':0.5,
- 'C':0.2,
- 'AT':0.4,
- 'AC':0.3,
- 'AG':0.2,
- 'TA':0.2,
- 'TC':0.3,
- 'TG':0.4,
- 'CT':0.2,
- 'CG':0.3,
- 'CA':0.2,
- 'GA':0.1,
- 'GT':0.4,
- 'GC':0.1,
- }
-
-extreme_data = {
- 'A':0.75,
- 'T':0.10,
- 'G':0.10,
- 'C':0.05,
- 'AT':0.6,
- 'AC':0.3,
- 'AG':0.1,
- 'TA':0.02,
- 'TC':0.3,
- 'TG':0.01,
- 'CT':0.2,
- 'CG':0.5,
- 'CA':0.2,
- 'GA':0.1,
- 'GT':0.4,
- 'GC':0.2,
- }
-
-sample_data = {
- 'A':0.2137,
- 'T':0.3541,
- 'G':0.1946,
- 'C':0.2376,
- 'AT':0.0228,
- 'AC':0.0684,
- 'AG':0.2056,
- 'TA':0.0315,
- 'TC':0.0629,
- 'TG':0.0315,
- 'CT':0.1355,
- 'CG':0.0401,
- 'CA':0.0703,
- 'GA':0.1824,
- 'GT':0.0387,
- 'GC':0.1106,
- }
-
-
-if __name__ == '__main__':
- from sys import argv
- d = None
- if len(argv) > 1:
- if argv[1] == 'full':
- d = all_on_max
- scaled = False
- elif argv[1] == 'extreme':
- d = extreme_data
- scaled = False
- elif argv[1] == 'realistic':
- d = realistic_data
- scaled = False
- elif argv[1] == 'sample':
- d = sample_data
- scaled = True
- if d is None:
- d = all_on_max
- scaled=False
- if len(argv) > 2:
- display = argv[2]
- else:
- display = 'length'
-
- size = 4
- figure(figsize=(size,size))
-
- make_arrow_plot(d, display=display, linewidth=0.001, edgecolor=None,
- normalize_data=scaled, head_starts_at_zero=True, size=size)
-
- draw()
- #savefig('arrows.png')
- #print 'Example saved to file "arrows.png"'
- show()
Deleted: trunk/matplotlib/doc/pyplots/axhspan_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/axhspan_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/axhspan_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,32 +0,0 @@
-import numpy as np
-import matplotlib.pyplot as plt
-
-t = np.arange(-1,2, .01)
-s = np.sin(2*np.pi*t)
-
-plt.plot(t,s)
-# draw a thick red hline at y=0 that spans the xrange
-l = plt.axhline(linewidth=4, color='r')
-
-# draw a default hline at y=1 that spans the xrange
-l = plt.axhline(y=1)
-
-# draw a default vline at x=1 that spans the xrange
-l = plt.axvline(x=1)
-
-# draw a thick blue vline at x=0 that spans the the upper quadrant of
-# the yrange
-l = plt.axvline(x=0, ymin=0.75, linewidth=4, color='b')
-
-# draw a default hline at y=.5 that spans the the middle half of
-# the axes
-l = plt.axhline(y=.5, xmin=0.25, xmax=0.75)
-
-p = plt.axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
-
-p = plt.axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
-
-plt.axis([-1,2,-1,2])
-
-
-plt.show()
Deleted: trunk/matplotlib/doc/pyplots/bar_stacked.py
===================================================================
--- trunk/matplotlib/doc/pyplots/bar_stacked.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/bar_stacked.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,25 +0,0 @@
-#!/usr/bin/env python
-# a stacked bar plot with errorbars
-import numpy as np
-import matplotlib.pyplot as plt
-
-
-N = 5
-menMeans = (20, 35, 30, 35, 27)
-womenMeans = (25, 32, 34, 20, 25)
-menStd = (2, 3, 4, 1, 2)
-womenStd = (3, 5, 2, 3, 3)
-ind = np.arange(N) # the x locations for the groups
-width = 0.35 # the width of the bars: can also be len(x) sequence
-
-p1 = plt.bar(ind, menMeans, width, color='r', yerr=womenStd)
-p2 = plt.bar(ind, womenMeans, width, color='y',
- bottom=menMeans, yerr=menStd)
-
-plt.ylabel('Scores')
-plt.title('Scores by group and gender')
-plt.xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') )
-plt.yticks(np.arange(0,81,10))
-plt.legend( (p1[0], p2[0]), ('Men', 'Women') )
-
-plt.show()
Deleted: trunk/matplotlib/doc/pyplots/broken_barh.py
===================================================================
--- trunk/matplotlib/doc/pyplots/broken_barh.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/broken_barh.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,24 +0,0 @@
-"""
-Make a "broken" horizontal bar plot, ie one with gaps
-"""
-import matplotlib.pyplot as plt
-
-fig = plt.figure()
-ax = fig.add_subplot(111)
-ax.broken_barh([ (110, 30), (150, 10) ] , (10, 9), facecolors='blue')
-ax.broken_barh([ (10, 50), (100, 20), (130, 10)] , (20, 9),
- facecolors=('red', 'yellow', 'green'))
-ax.set_ylim(5,35)
-ax.set_xlim(0,200)
-ax.set_xlabel('seconds since start')
-ax.set_yticks([15,25])
-ax.set_yticklabels(['Bill', 'Jim'])
-ax.grid(True)
-ax.annotate('race interrupted', (61, 25),
- xytext=(0.8, 0.9), textcoords='axes fraction',
- arrowprops=dict(facecolor='black', shrink=0.05),
- fontsize=16,
- horizontalalignment='right', verticalalignment='top')
-
-#fig.savefig('broken_barh', dpi=100)
-plt.show()
Deleted: trunk/matplotlib/doc/pyplots/cohere_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/cohere_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/cohere_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-"""
-Compute the coherence of two signals
-"""
-import numpy as np
-import matplotlib.pyplot as plt
-
-# make a little extra space between the subplots
-plt.subplots_adjust(wspace=0.5)
-
-dt = 0.01
-t = np.arange(0, 30, dt)
-nse1 = np.random.randn(len(t)) # white noise 1
-nse2 = np.random.randn(len(t)) # white noise 2
-r = np.exp(-t/0.05)
-
-cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1
-cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2
-
-# two signals with a coherent part and a random part
-s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1
-s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2
-
-plt.subplot(211)
-plt.plot(t, s1, 'b-', t, s2, 'g-')
-plt.xlim(0,5)
-plt.xlabel('time')
-plt.ylabel('s1 and s2')
-plt.grid(True)
-
-plt.subplot(212)
-cxy, f = plt.cohere(s1, s2, 256, 1./dt)
-plt.ylabel('coherence')
-plt.show()
-
-
Deleted: trunk/matplotlib/doc/pyplots/csd_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/csd_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/csd_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-"""
-Compute the cross spectral density of two signals
-"""
-import numpy as np
-import matplotlib.pyplot as plt
-
-# make a little extra space between the subplots
-plt.subplots_adjust(wspace=0.5)
-
-dt = 0.01
-t = np.arange(0, 30, dt)
-nse1 = np.random.randn(len(t)) # white noise 1
-nse2 = np.random.randn(len(t)) # white noise 2
-r = np.exp(-t/0.05)
-
-cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1
-cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2
-
-# two signals with a coherent part and a random part
-s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1
-s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2
-
-plt.subplot(211)
-plt.plot(t, s1, 'b-', t, s2, 'g-')
-plt.xlim(0,5)
-plt.xlabel('time')
-plt.ylabel('s1 and s2')
-plt.grid(True)
-
-plt.subplot(212)
-cxy, f = plt.csd(s1, s2, 256, 1./dt)
-plt.ylabel('CSD (db)')
-plt.show()
-
-
Deleted: trunk/matplotlib/doc/pyplots/figimage_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/figimage_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/figimage_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,21 +0,0 @@
-"""
-See pcolor_demo2 for a much faster way of generating pcolor plots
-"""
-import numpy as np
-import matplotlib
-import matplotlib.cm as cm
-import matplotlib.pyplot as plt
-
-
-fig = plt.figure(frameon=False)
-Z = np.arange(10000.0)
-Z.shape = 100,100
-Z[:,50:] = 1.
-
-im1 = plt.figimage(Z, xo=50, yo=0, cmap=cm.jet)
-im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, cmap=cm.jet)
-
-plt.show()
-
-
-
Deleted: trunk/matplotlib/doc/pyplots/figlegend_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/figlegend_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/figlegend_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,19 +0,0 @@
-import numpy as np
-import matplotlib.pyplot as plt
-
-fig = plt.figure()
-ax1 = fig.add_axes([0.1, 0.1, 0.4, 0.7])
-ax2 = fig.add_axes([0.55, 0.1, 0.4, 0.7])
-
-x = np.arange(0.0, 2.0, 0.02)
-y1 = np.sin(2*np.pi*x)
-y2 = np.exp(-x)
-l1, l2 = ax1.plot(x, y1, 'rs-', x, y2, 'go')
-
-y3 = np.sin(4*np.pi*x)
-y4 = np.exp(-2*x)
-l3, l4 = ax2.plot(x, y3, 'yd-', x, y3, 'k^')
-
-fig.legend((l1, l2), ('Line 1', 'Line 2'), 'upper left')
-fig.legend((l3, l4), ('Line 3', 'Line 4'), 'upper right')
-plt.show()
Deleted: trunk/matplotlib/doc/pyplots/fill_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/fill_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/fill_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,10 +0,0 @@
-#!/usr/bin/env python
-import numpy as np
-import matplotlib.pyplot as plt
-
-t = np.arange(0.0, 1.01, 0.01)
-s = np.sin(2*2*np.pi*t)
-
-plt.fill(t, s*np.exp(-5*t), 'r')
-plt.grid(True)
-plt.show()
Deleted: trunk/matplotlib/doc/pyplots/hexbin_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/hexbin_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/hexbin_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,34 +0,0 @@
-"""
-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'.
-"""
-
-import numpy as np
-import matplotlib.pyplot as plt
-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()
-
-plt.subplots_adjust(hspace=0.5)
-plt.subplot(121)
-plt.hexbin(x,y)
-plt.axis([xmin, xmax, ymin, ymax])
-plt.title("Hexagon binning")
-cb = plt.colorbar()
-cb.set_label('counts')
-
-plt.subplot(122)
-plt.hexbin(x,y,bins='log')
-plt.axis([xmin, xmax, ymin, ymax])
-plt.title("With a log color scale")
-cb = plt.colorbar()
-cb.set_label('log10(N)')
-
-plt.show()
-
Deleted: trunk/matplotlib/doc/pyplots/histogram_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/histogram_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/histogram_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,22 +0,0 @@
-#!/usr/bin/env python
-import numpy as np
-import matplotlib.mlab as mlab
-import matplotlib.pyplot as plt
-
-mu, sigma = 100, 15
-x = mu + sigma*np.random.randn(10000)
-
-# the histogram of the data
-n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75)
-
-# add a 'best fit' line
-y = mlab.normpdf( bins, mu, sigma)
-l = plt.plot(bins, y, 'r--', linewidth=1)
-
-plt.xlabel('Smarts')
-plt.ylabel('Probability')
-plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
-plt.axis([40, 160, 0, 0.03])
-plt.grid(True)
-
-plt.show()
Deleted: trunk/matplotlib/doc/pyplots/image_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/image_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/image_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,18 +0,0 @@
-#!/usr/bin/env python
-import numpy as np
-import matplotlib.cm as cm
-import matplotlib.mlab as mlab
-import matplotlib.pyplot as plt
-
-delta = 0.025
-x = y = np.arange(-3.0, 3.0, delta)
-X, Y = np.meshgrid(x, y)
-Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
-Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
-Z = Z2-Z1 # difference of Gaussians
-
-im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
- origin='lower', extent=[-3,3,-3,3])
-
-plt.show()
-
Deleted: trunk/matplotlib/doc/pyplots/log_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/log_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/log_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,25 +0,0 @@
-import numpy as np
-import matplotlib.pyplot as plt
-
-plt.subplots_adjust(hspace=0.4)
-t = np.arange(0.01, 20.0, 0.01)
-
-# log y axis
-plt.subplot(311)
-plt.semilogy(t, np.exp(-t/5.0))
-plt.ylabel('semilogy')
-plt.grid(True)
-
-# log x axis
-plt.subplot(312)
-plt.semilogx(t, np.sin(2*np.pi*t))
-plt.ylabel('semilogx')
-plt.grid(True)
-
-# log x and y axis
-plt.subplot(313)
-plt.loglog(t, 20*np.exp(-t/10.0), basex=4)
-plt.grid(True)
-plt.ylabel('loglog base 4 on x')
-
-plt.show()
Deleted: trunk/matplotlib/doc/pyplots/xcorr_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/xcorr_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
+++ trunk/matplotlib/doc/pyplots/xcorr_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
@@ -1,17 +0,0 @@
-import matplotlib.pyplot as plt
-import numpy as np
-
-x,y = np.random.randn(2,100)
-fig = plt.figure()
-ax1 = fig.add_subplot(211)
-ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2)
-ax1.grid(True)
-ax1.axhline(0, color='black', lw=2)
-
-ax2 = fig.add_subplot(212, sharex=ax1)
-ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2)
-ax2.grid(True)
-ax2.axhline(0, color='black', lw=2)
-
-plt.show()
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-27 15:51:55
|
Revision: 5690
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5690&view=rev
Author: jdh2358
Date: 2008-06-27 08:34:32 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
added pyplots examples which I forgot to svn add in prev commit
Added Paths:
-----------
trunk/matplotlib/doc/pyplots/arrow_demo.py
trunk/matplotlib/doc/pyplots/axhspan_demo.py
trunk/matplotlib/doc/pyplots/bar_stacked.py
trunk/matplotlib/doc/pyplots/boxplot_demo.py
trunk/matplotlib/doc/pyplots/broken_barh.py
trunk/matplotlib/doc/pyplots/cohere_demo.py
trunk/matplotlib/doc/pyplots/contour_demo.py
trunk/matplotlib/doc/pyplots/csd_demo.py
trunk/matplotlib/doc/pyplots/errorbar_demo.py
trunk/matplotlib/doc/pyplots/figimage_demo.py
trunk/matplotlib/doc/pyplots/figlegend_demo.py
trunk/matplotlib/doc/pyplots/fill_demo.py
trunk/matplotlib/doc/pyplots/hexbin_demo.py
trunk/matplotlib/doc/pyplots/histogram_demo.py
trunk/matplotlib/doc/pyplots/hline_demo.py
trunk/matplotlib/doc/pyplots/image_demo.py
trunk/matplotlib/doc/pyplots/log_demo.py
trunk/matplotlib/doc/pyplots/xcorr_demo.py
Added: trunk/matplotlib/doc/pyplots/arrow_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/arrow_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/arrow_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,313 @@
+#!/usr/bin/env python
+"""Arrow drawing example for the new fancy_arrow facilities.
+
+Code contributed by: Rob Knight <ro...@sp...>
+
+usage:
+
+ python arrow_demo.py realistic|full|sample|extreme
+
+
+"""
+from pylab import *
+
+rates_to_bases={'r1':'AT', 'r2':'TA', 'r3':'GA','r4':'AG','r5':'CA','r6':'AC', \
+ 'r7':'GT', 'r8':'TG', 'r9':'CT','r10':'TC','r11':'GC','r12':'CG'}
+numbered_bases_to_rates = dict([(v,k) for k, v in rates_to_bases.items()])
+lettered_bases_to_rates = dict([(v, 'r'+v) for k, v in rates_to_bases.items()])
+def add_dicts(d1, d2):
+ """Adds two dicts and returns the result."""
+ result = d1.copy()
+ result.update(d2)
+ return result
+
+def make_arrow_plot(data, size=4, display='length', shape='right', \
+ max_arrow_width=0.03, arrow_sep = 0.02, alpha=0.5, \
+ normalize_data=False, ec=None, labelcolor=None, \
+ head_starts_at_zero=True, rate_labels=lettered_bases_to_rates,\
+ **kwargs):
+ """Makes an arrow plot.
+
+ Parameters:
+
+ data: dict with probabilities for the bases and pair transitions.
+ size: size of the graph in inches.
+ display: 'length', 'width', or 'alpha' for arrow property to change.
+ shape: 'full', 'left', or 'right' for full or half arrows.
+ max_arrow_width: maximum width of an arrow, data coordinates.
+ arrow_sep: separation between arrows in a pair, data coordinates.
+ alpha: maximum opacity of arrows, default 0.8.
+
+ **kwargs can be anything allowed by a Arrow object, e.g.
+ linewidth and edgecolor.
+ """
+
+ xlim(-0.5,1.5)
+ ylim(-0.5,1.5)
+ gcf().set_size_inches(size,size)
+ xticks([])
+ yticks([])
+ max_text_size = size*12
+ min_text_size = size
+ label_text_size = size*2.5
+ text_params={'ha':'center', 'va':'center', 'family':'sans-serif',\
+ 'fontweight':'bold'}
+ r2 = sqrt(2)
+
+ deltas = {\
+ 'AT':(1,0),
+ 'TA':(-1,0),
+ 'GA':(0,1),
+ 'AG':(0,-1),
+ 'CA':(-1/r2, 1/r2),
+ 'AC':(1/r2, -1/r2),
+ 'GT':(1/r2, 1/r2),
+ 'TG':(-1/r2,-1/r2),
+ 'CT':(0,1),
+ 'TC':(0,-1),
+ 'GC':(1,0),
+ 'CG':(-1,0)
+ }
+
+ colors = {\
+ 'AT':'r',
+ 'TA':'k',
+ 'GA':'g',
+ 'AG':'r',
+ 'CA':'b',
+ 'AC':'r',
+ 'GT':'g',
+ 'TG':'k',
+ 'CT':'b',
+ 'TC':'k',
+ 'GC':'g',
+ 'CG':'b'
+ }
+
+ label_positions = {\
+ 'AT':'center',
+ 'TA':'center',
+ 'GA':'center',
+ 'AG':'center',
+ 'CA':'left',
+ 'AC':'left',
+ 'GT':'left',
+ 'TG':'left',
+ 'CT':'center',
+ 'TC':'center',
+ 'GC':'center',
+ 'CG':'center'
+ }
+
+
+ def do_fontsize(k):
+ return float(clip(max_text_size*sqrt(data[k]),\
+ min_text_size,max_text_size))
+
+ A = text(0,1, '$A_3$', color='r', size=do_fontsize('A'), **text_params)
+ T = text(1,1, '$T_3$', color='k', size=do_fontsize('T'), **text_params)
+ G = text(0,0, '$G_3$', color='g', size=do_fontsize('G'), **text_params)
+ C = text(1,0, '$C_3$', color='b', size=do_fontsize('C'), **text_params)
+
+ arrow_h_offset = 0.25 #data coordinates, empirically determined
+ max_arrow_length = 1 - 2*arrow_h_offset
+
+ max_arrow_width = max_arrow_width
+ max_head_width = 2.5*max_arrow_width
+ max_head_length = 2*max_arrow_width
+ arrow_params={'length_includes_head':True, 'shape':shape, \
+ 'head_starts_at_zero':head_starts_at_zero}
+ ax = gca()
+ sf = 0.6 #max arrow size represents this in data coords
+
+ d = (r2/2 + arrow_h_offset - 0.5)/r2 #distance for diags
+ r2v = arrow_sep/r2 #offset for diags
+
+ #tuple of x, y for start position
+ positions = {\
+ 'AT': (arrow_h_offset, 1+arrow_sep),
+ 'TA': (1-arrow_h_offset, 1-arrow_sep),
+ 'GA': (-arrow_sep, arrow_h_offset),
+ 'AG': (arrow_sep, 1-arrow_h_offset),
+ 'CA': (1-d-r2v, d-r2v),
+ 'AC': (d+r2v, 1-d+r2v),
+ 'GT': (d-r2v, d+r2v),
+ 'TG': (1-d+r2v, 1-d-r2v),
+ 'CT': (1-arrow_sep, arrow_h_offset),
+ 'TC': (1+arrow_sep, 1-arrow_h_offset),
+ 'GC': (arrow_h_offset, arrow_sep),
+ 'CG': (1-arrow_h_offset, -arrow_sep),
+ }
+
+ if normalize_data:
+ #find maximum value for rates, i.e. where keys are 2 chars long
+ max_val = 0
+ for k, v in data.items():
+ if len(k) == 2:
+ max_val = max(max_val, v)
+ #divide rates by max val, multiply by arrow scale factor
+ for k, v in data.items():
+ data[k] = v/max_val*sf
+
+ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor):
+ #set the length of the arrow
+ if display == 'length':
+ length = max_head_length+(max_arrow_length-max_head_length)*\
+ data[pair]/sf
+ else:
+ length = max_arrow_length
+ #set the transparency of the arrow
+ if display == 'alph':
+ alpha = min(data[pair]/sf, alpha)
+ else:
+ alpha=alpha
+ #set the width of the arrow
+ if display == 'width':
+ scale = data[pair]/sf
+ width = max_arrow_width*scale
+ head_width = max_head_width*scale
+ head_length = max_head_length*scale
+ else:
+ width = max_arrow_width
+ head_width = max_head_width
+ head_length = max_head_length
+
+ fc = colors[pair]
+ ec = ec or fc
+
+ x_scale, y_scale = deltas[pair]
+ x_pos, y_pos = positions[pair]
+ arrow(x_pos, y_pos, x_scale*length, y_scale*length, \
+ fc=fc, ec=ec, alpha=alpha, width=width, head_width=head_width, \
+ head_length=head_length, **arrow_params)
+
+ #figure out coordinates for text
+ #if drawing relative to base: x and y are same as for arrow
+ #dx and dy are one arrow width left and up
+ #need to rotate based on direction of arrow, use x_scale and y_scale
+ #as sin x and cos x?
+ sx, cx = y_scale, x_scale
+
+ where = label_positions[pair]
+ if where == 'left':
+ orig_position = 3*array([[max_arrow_width, max_arrow_width]])
+ elif where == 'absolute':
+ orig_position = array([[max_arrow_length/2.0, 3*max_arrow_width]])
+ elif where == 'right':
+ orig_position = array([[length-3*max_arrow_width,\
+ 3*max_arrow_width]])
+ elif where == 'center':
+ orig_position = array([[length/2.0, 3*max_arrow_width]])
+ else:
+ raise ValueError, "Got unknown position parameter %s" % where
+
+
+
+ M = array([[cx, sx],[-sx,cx]])
+ coords = dot(orig_position, M) + [[x_pos, y_pos]]
+ x, y = ravel(coords)
+ orig_label = rate_labels[pair]
+ label = '$%s_{_{\mathrm{%s}}}$' % (orig_label[0], orig_label[1:])
+
+ text(x, y, label, size=label_text_size, ha='center', va='center', \
+ color=labelcolor or fc)
+
+ for p in positions.keys():
+ draw_arrow(p)
+
+ #test data
+all_on_max = dict([(i, 1) for i in 'TCAG'] + \
+ [(i+j, 0.6) for i in 'TCAG' for j in 'TCAG'])
+
+realistic_data = {
+ 'A':0.4,
+ 'T':0.3,
+ 'G':0.5,
+ 'C':0.2,
+ 'AT':0.4,
+ 'AC':0.3,
+ 'AG':0.2,
+ 'TA':0.2,
+ 'TC':0.3,
+ 'TG':0.4,
+ 'CT':0.2,
+ 'CG':0.3,
+ 'CA':0.2,
+ 'GA':0.1,
+ 'GT':0.4,
+ 'GC':0.1,
+ }
+
+extreme_data = {
+ 'A':0.75,
+ 'T':0.10,
+ 'G':0.10,
+ 'C':0.05,
+ 'AT':0.6,
+ 'AC':0.3,
+ 'AG':0.1,
+ 'TA':0.02,
+ 'TC':0.3,
+ 'TG':0.01,
+ 'CT':0.2,
+ 'CG':0.5,
+ 'CA':0.2,
+ 'GA':0.1,
+ 'GT':0.4,
+ 'GC':0.2,
+ }
+
+sample_data = {
+ 'A':0.2137,
+ 'T':0.3541,
+ 'G':0.1946,
+ 'C':0.2376,
+ 'AT':0.0228,
+ 'AC':0.0684,
+ 'AG':0.2056,
+ 'TA':0.0315,
+ 'TC':0.0629,
+ 'TG':0.0315,
+ 'CT':0.1355,
+ 'CG':0.0401,
+ 'CA':0.0703,
+ 'GA':0.1824,
+ 'GT':0.0387,
+ 'GC':0.1106,
+ }
+
+
+if __name__ == '__main__':
+ from sys import argv
+ d = None
+ if len(argv) > 1:
+ if argv[1] == 'full':
+ d = all_on_max
+ scaled = False
+ elif argv[1] == 'extreme':
+ d = extreme_data
+ scaled = False
+ elif argv[1] == 'realistic':
+ d = realistic_data
+ scaled = False
+ elif argv[1] == 'sample':
+ d = sample_data
+ scaled = True
+ if d is None:
+ d = all_on_max
+ scaled=False
+ if len(argv) > 2:
+ display = argv[2]
+ else:
+ display = 'length'
+
+ size = 4
+ figure(figsize=(size,size))
+
+ make_arrow_plot(d, display=display, linewidth=0.001, edgecolor=None,
+ normalize_data=scaled, head_starts_at_zero=True, size=size)
+
+ draw()
+ #savefig('arrows.png')
+ #print 'Example saved to file "arrows.png"'
+ show()
Added: trunk/matplotlib/doc/pyplots/axhspan_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/axhspan_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/axhspan_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,32 @@
+import numpy as np
+import matplotlib.pyplot as plt
+
+t = np.arange(-1,2, .01)
+s = np.sin(2*np.pi*t)
+
+plt.plot(t,s)
+# draw a thick red hline at y=0 that spans the xrange
+l = plt.axhline(linewidth=4, color='r')
+
+# draw a default hline at y=1 that spans the xrange
+l = plt.axhline(y=1)
+
+# draw a default vline at x=1 that spans the xrange
+l = plt.axvline(x=1)
+
+# draw a thick blue vline at x=0 that spans the the upper quadrant of
+# the yrange
+l = plt.axvline(x=0, ymin=0.75, linewidth=4, color='b')
+
+# draw a default hline at y=.5 that spans the the middle half of
+# the axes
+l = plt.axhline(y=.5, xmin=0.25, xmax=0.75)
+
+p = plt.axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
+
+p = plt.axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
+
+plt.axis([-1,2,-1,2])
+
+
+plt.show()
Added: trunk/matplotlib/doc/pyplots/bar_stacked.py
===================================================================
--- trunk/matplotlib/doc/pyplots/bar_stacked.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/bar_stacked.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# a stacked bar plot with errorbars
+import numpy as np
+import matplotlib.pyplot as plt
+
+
+N = 5
+menMeans = (20, 35, 30, 35, 27)
+womenMeans = (25, 32, 34, 20, 25)
+menStd = (2, 3, 4, 1, 2)
+womenStd = (3, 5, 2, 3, 3)
+ind = np.arange(N) # the x locations for the groups
+width = 0.35 # the width of the bars: can also be len(x) sequence
+
+p1 = plt.bar(ind, menMeans, width, color='r', yerr=womenStd)
+p2 = plt.bar(ind, womenMeans, width, color='y',
+ bottom=menMeans, yerr=menStd)
+
+plt.ylabel('Scores')
+plt.title('Scores by group and gender')
+plt.xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') )
+plt.yticks(np.arange(0,81,10))
+plt.legend( (p1[0], p2[0]), ('Men', 'Women') )
+
+plt.show()
Added: trunk/matplotlib/doc/pyplots/boxplot_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/boxplot_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/boxplot_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,145 @@
+import numpy as np
+import matplotlib.pyplot as plt
+
+spread = np.random.rand(50) * 100
+center = np.ones(25) * 50
+flier_high = np.random.rand(10) * 100 + 100
+flier_low = np.random.rand(10) * -100
+data = np.concatenate((spread, center, flier_high, flier_low), 0)
+
+# fake up some more data
+spread = np.random.rand(50) * 100
+center = np.ones(25) * 40
+flier_high = np.random.rand(10) * 100 + 100
+flier_low = np.random.rand(10) * -100
+d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
+data.shape = (-1, 1)
+d2.shape = (-1, 1)
+
+#data = concatenate( (data, d2), 1 )
+# Making a 2-D array only works if all the columns are the
+# same length. If they are not, then use a list instead.
+# This is actually more efficient because boxplot converts
+# a 2-D array into a list of vectors internally anyway.
+data = [data, d2, d2[::2,0]]
+# multiple box plots on one figure
+
+plt.boxplot(data)
+plt.show()
+
+import numpy as np
+import matplotlib.pyplot as plt
+
+spread = np.random.rand(50) * 100
+center = np.ones(25) * 50
+flier_high = np.random.rand(10) * 100 + 100
+flier_low = np.random.rand(10) * -100
+data = np.concatenate((spread, center, flier_high, flier_low), 0)
+
+# fake up some more data
+spread = np.random.rand(50) * 100
+center = np.ones(25) * 40
+flier_high = np.random.rand(10) * 100 + 100
+flier_low = np.random.rand(10) * -100
+d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
+data.shape = (-1, 1)
+d2.shape = (-1, 1)
+
+#data = concatenate( (data, d2), 1 )
+# Making a 2-D array only works if all the columns are the
+# same length. If they are not, then use a list instead.
+# This is actually more efficient because boxplot converts
+# a 2-D array into a list of vectors internally anyway.
+data = [data, d2, d2[::2,0]]
+# multiple box plots on one figure
+
+plt.boxplot(data)
+plt.show()
+
+import numpy as np
+import matplotlib.pyplot as plt
+
+spread = np.random.rand(50) * 100
+center = np.ones(25) * 50
+flier_high = np.random.rand(10) * 100 + 100
+flier_low = np.random.rand(10) * -100
+data = np.concatenate((spread, center, flier_high, flier_low), 0)
+
+# fake up some more data
+spread = np.random.rand(50) * 100
+center = np.ones(25) * 40
+flier_high = np.random.rand(10) * 100 + 100
+flier_low = np.random.rand(10) * -100
+d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
+data.shape = (-1, 1)
+d2.shape = (-1, 1)
+
+#data = concatenate( (data, d2), 1 )
+# Making a 2-D array only works if all the columns are the
+# same length. If they are not, then use a list instead.
+# This is actually more efficient because boxplot converts
+# a 2-D array into a list of vectors internally anyway.
+data = [data, d2, d2[::2,0]]
+# multiple box plots on one figure
+
+plt.boxplot(data)
+plt.show()
+
+import numpy as np
+import matplotlib.pyplot as plt
+
+spread = np.random.rand(50) * 100
+center = np.ones(25) * 50
+flier_high = np.random.rand(10) * 100 + 100
+flier_low = np.random.rand(10) * -100
+data = np.concatenate((spread, center, flier_high, flier_low), 0)
+
+# fake up some more data
+spread = np.random.rand(50) * 100
+center = np.ones(25) * 40
+flier_high = np.random.rand(10) * 100 + 100
+flier_low = np.random.rand(10) * -100
+d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
+data.shape = (-1, 1)
+d2.shape = (-1, 1)
+
+#data = concatenate( (data, d2), 1 )
+# Making a 2-D array only works if all the columns are the
+# same length. If they are not, then use a list instead.
+# This is actually more efficient because boxplot converts
+# a 2-D array into a list of vectors internally anyway.
+data = [data, d2, d2[::2,0]]
+# multiple box plots on one figure
+
+plt.boxplot(data)
+plt.show()
+
+import numpy as np
+import matplotlib.pyplot as plt
+
+spread = np.random.rand(50) * 100
+center = np.ones(25) * 50
+flier_high = np.random.rand(10) * 100 + 100
+flier_low = np.random.rand(10) * -100
+data = np.concatenate((spread, center, flier_high, flier_low), 0)
+
+# fake up some more data
+spread = np.random.rand(50) * 100
+center = np.ones(25) * 40
+flier_high = np.random.rand(10) * 100 + 100
+flier_low = np.random.rand(10) * -100
+d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
+data.shape = (-1, 1)
+d2.shape = (-1, 1)
+
+#data = concatenate( (data, d2), 1 )
+# Making a 2-D array only works if all the columns are the
+# same length. If they are not, then use a list instead.
+# This is actually more efficient because boxplot converts
+# a 2-D array into a list of vectors internally anyway.
+data = [data, d2, d2[::2,0]]
+# multiple box plots on one figure
+
+plt.boxplot(data)
+plt.show()
+
Added: trunk/matplotlib/doc/pyplots/broken_barh.py
===================================================================
--- trunk/matplotlib/doc/pyplots/broken_barh.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/broken_barh.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,24 @@
+"""
+Make a "broken" horizontal bar plot, ie one with gaps
+"""
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.broken_barh([ (110, 30), (150, 10) ] , (10, 9), facecolors='blue')
+ax.broken_barh([ (10, 50), (100, 20), (130, 10)] , (20, 9),
+ facecolors=('red', 'yellow', 'green'))
+ax.set_ylim(5,35)
+ax.set_xlim(0,200)
+ax.set_xlabel('seconds since start')
+ax.set_yticks([15,25])
+ax.set_yticklabels(['Bill', 'Jim'])
+ax.grid(True)
+ax.annotate('race interrupted', (61, 25),
+ xytext=(0.8, 0.9), textcoords='axes fraction',
+ arrowprops=dict(facecolor='black', shrink=0.05),
+ fontsize=16,
+ horizontalalignment='right', verticalalignment='top')
+
+#fig.savefig('broken_barh', dpi=100)
+plt.show()
Added: trunk/matplotlib/doc/pyplots/cohere_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/cohere_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/cohere_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+"""
+Compute the coherence of two signals
+"""
+import numpy as np
+import matplotlib.pyplot as plt
+
+# make a little extra space between the subplots
+plt.subplots_adjust(wspace=0.5)
+
+dt = 0.01
+t = np.arange(0, 30, dt)
+nse1 = np.random.randn(len(t)) # white noise 1
+nse2 = np.random.randn(len(t)) # white noise 2
+r = np.exp(-t/0.05)
+
+cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1
+cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2
+
+# two signals with a coherent part and a random part
+s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1
+s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2
+
+plt.subplot(211)
+plt.plot(t, s1, 'b-', t, s2, 'g-')
+plt.xlim(0,5)
+plt.xlabel('time')
+plt.ylabel('s1 and s2')
+plt.grid(True)
+
+plt.subplot(212)
+cxy, f = plt.cohere(s1, s2, 256, 1./dt)
+plt.ylabel('coherence')
+plt.show()
+
+
Added: trunk/matplotlib/doc/pyplots/contour_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/contour_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/contour_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,330 @@
+#!/usr/bin/env python
+"""
+Illustrate simple contour plotting, contours on an image with
+a colorbar for the contours, and labelled contours.
+
+See also contour_image.py.
+"""
+import matplotlib
+import numpy as np
+import matplotlib.cm as cm
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
+
+matplotlib.rcParams['xtick.direction'] = 'out'
+matplotlib.rcParams['ytick.direction'] = 'out'
+
+delta = 0.025
+x = np.arange(-3.0, 3.0, delta)
+y = np.arange(-2.0, 2.0, delta)
+X, Y = np.meshgrid(x, y)
+Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
+Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
+# difference of Gaussians
+Z = 10.0 * (Z2 - Z1)
+
+
+# You can use a colormap to specify the colors; the default
+# colormap will be used for the contour lines
+plt.figure()
+im = plt.imshow(Z, interpolation='bilinear', origin='lower',
+ cmap=cm.gray, extent=(-3,3,-2,2))
+levels = np.arange(-1.2, 1.6, 0.2)
+CS = plt.contour(Z, levels,
+ origin='lower',
+ linewidths=2,
+ extent=(-3,3,-2,2))
+
+#Thicken the zero contour.
+zc = CS.collections[6]
+plt.setp(zc, linewidth=4)
+
+plt.clabel(CS, levels[1::2], # label every second level
+ inline=1,
+ fmt='%1.1f',
+ fontsize=14)
+
+# make a colorbar for the contour lines
+CB = plt.colorbar(CS, shrink=0.8, extend='both')
+
+plt.title('Lines with colorbar')
+#plt.hot() # Now change the colormap for the contour lines and colorbar
+plt.flag()
+
+# We can still add a colorbar for the image, too.
+CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
+
+# This makes the original colorbar look a bit out of place,
+# so let's improve its position.
+
+l,b,w,h = plt.gca().get_position().bounds
+ll,bb,ww,hh = CB.ax.get_position().bounds
+CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
+
+
+#savefig('contour_demo')
+plt.show()
+#!/usr/bin/env python
+"""
+Illustrate simple contour plotting, contours on an image with
+a colorbar for the contours, and labelled contours.
+
+See also contour_image.py.
+"""
+import matplotlib
+import numpy as np
+import matplotlib.cm as cm
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
+
+matplotlib.rcParams['xtick.direction'] = 'out'
+matplotlib.rcParams['ytick.direction'] = 'out'
+
+delta = 0.025
+x = np.arange(-3.0, 3.0, delta)
+y = np.arange(-2.0, 2.0, delta)
+X, Y = np.meshgrid(x, y)
+Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
+Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
+# difference of Gaussians
+Z = 10.0 * (Z2 - Z1)
+
+
+# You can use a colormap to specify the colors; the default
+# colormap will be used for the contour lines
+plt.figure()
+im = plt.imshow(Z, interpolation='bilinear', origin='lower',
+ cmap=cm.gray, extent=(-3,3,-2,2))
+levels = np.arange(-1.2, 1.6, 0.2)
+CS = plt.contour(Z, levels,
+ origin='lower',
+ linewidths=2,
+ extent=(-3,3,-2,2))
+
+#Thicken the zero contour.
+zc = CS.collections[6]
+plt.setp(zc, linewidth=4)
+
+plt.clabel(CS, levels[1::2], # label every second level
+ inline=1,
+ fmt='%1.1f',
+ fontsize=14)
+
+# make a colorbar for the contour lines
+CB = plt.colorbar(CS, shrink=0.8, extend='both')
+
+plt.title('Lines with colorbar')
+#plt.hot() # Now change the colormap for the contour lines and colorbar
+plt.flag()
+
+# We can still add a colorbar for the image, too.
+CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
+
+# This makes the original colorbar look a bit out of place,
+# so let's improve its position.
+
+l,b,w,h = plt.gca().get_position().bounds
+ll,bb,ww,hh = CB.ax.get_position().bounds
+CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
+
+
+#savefig('contour_demo')
+plt.show()
+#!/usr/bin/env python
+"""
+Illustrate simple contour plotting, contours on an image with
+a colorbar for the contours, and labelled contours.
+
+See also contour_image.py.
+"""
+import matplotlib
+import numpy as np
+import matplotlib.cm as cm
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
+
+matplotlib.rcParams['xtick.direction'] = 'out'
+matplotlib.rcParams['ytick.direction'] = 'out'
+
+delta = 0.025
+x = np.arange(-3.0, 3.0, delta)
+y = np.arange(-2.0, 2.0, delta)
+X, Y = np.meshgrid(x, y)
+Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
+Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
+# difference of Gaussians
+Z = 10.0 * (Z2 - Z1)
+
+
+# You can use a colormap to specify the colors; the default
+# colormap will be used for the contour lines
+plt.figure()
+im = plt.imshow(Z, interpolation='bilinear', origin='lower',
+ cmap=cm.gray, extent=(-3,3,-2,2))
+levels = np.arange(-1.2, 1.6, 0.2)
+CS = plt.contour(Z, levels,
+ origin='lower',
+ linewidths=2,
+ extent=(-3,3,-2,2))
+
+#Thicken the zero contour.
+zc = CS.collections[6]
+plt.setp(zc, linewidth=4)
+
+plt.clabel(CS, levels[1::2], # label every second level
+ inline=1,
+ fmt='%1.1f',
+ fontsize=14)
+
+# make a colorbar for the contour lines
+CB = plt.colorbar(CS, shrink=0.8, extend='both')
+
+plt.title('Lines with colorbar')
+#plt.hot() # Now change the colormap for the contour lines and colorbar
+plt.flag()
+
+# We can still add a colorbar for the image, too.
+CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
+
+# This makes the original colorbar look a bit out of place,
+# so let's improve its position.
+
+l,b,w,h = plt.gca().get_position().bounds
+ll,bb,ww,hh = CB.ax.get_position().bounds
+CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
+
+
+#savefig('contour_demo')
+plt.show()
+#!/usr/bin/env python
+"""
+Illustrate simple contour plotting, contours on an image with
+a colorbar for the contours, and labelled contours.
+
+See also contour_image.py.
+"""
+import matplotlib
+import numpy as np
+import matplotlib.cm as cm
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
+
+matplotlib.rcParams['xtick.direction'] = 'out'
+matplotlib.rcParams['ytick.direction'] = 'out'
+
+delta = 0.025
+x = np.arange(-3.0, 3.0, delta)
+y = np.arange(-2.0, 2.0, delta)
+X, Y = np.meshgrid(x, y)
+Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
+Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
+# difference of Gaussians
+Z = 10.0 * (Z2 - Z1)
+
+
+# You can use a colormap to specify the colors; the default
+# colormap will be used for the contour lines
+plt.figure()
+im = plt.imshow(Z, interpolation='bilinear', origin='lower',
+ cmap=cm.gray, extent=(-3,3,-2,2))
+levels = np.arange(-1.2, 1.6, 0.2)
+CS = plt.contour(Z, levels,
+ origin='lower',
+ linewidths=2,
+ extent=(-3,3,-2,2))
+
+#Thicken the zero contour.
+zc = CS.collections[6]
+plt.setp(zc, linewidth=4)
+
+plt.clabel(CS, levels[1::2], # label every second level
+ inline=1,
+ fmt='%1.1f',
+ fontsize=14)
+
+# make a colorbar for the contour lines
+CB = plt.colorbar(CS, shrink=0.8, extend='both')
+
+plt.title('Lines with colorbar')
+#plt.hot() # Now change the colormap for the contour lines and colorbar
+plt.flag()
+
+# We can still add a colorbar for the image, too.
+CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
+
+# This makes the original colorbar look a bit out of place,
+# so let's improve its position.
+
+l,b,w,h = plt.gca().get_position().bounds
+ll,bb,ww,hh = CB.ax.get_position().bounds
+CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
+
+
+#savefig('contour_demo')
+plt.show()
+#!/usr/bin/env python
+"""
+Illustrate simple contour plotting, contours on an image with
+a colorbar for the contours, and labelled contours.
+
+See also contour_image.py.
+"""
+import matplotlib
+import numpy as np
+import matplotlib.cm as cm
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
+
+matplotlib.rcParams['xtick.direction'] = 'out'
+matplotlib.rcParams['ytick.direction'] = 'out'
+
+delta = 0.025
+x = np.arange(-3.0, 3.0, delta)
+y = np.arange(-2.0, 2.0, delta)
+X, Y = np.meshgrid(x, y)
+Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
+Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
+# difference of Gaussians
+Z = 10.0 * (Z2 - Z1)
+
+
+# You can use a colormap to specify the colors; the default
+# colormap will be used for the contour lines
+plt.figure()
+im = plt.imshow(Z, interpolation='bilinear', origin='lower',
+ cmap=cm.gray, extent=(-3,3,-2,2))
+levels = np.arange(-1.2, 1.6, 0.2)
+CS = plt.contour(Z, levels,
+ origin='lower',
+ linewidths=2,
+ extent=(-3,3,-2,2))
+
+#Thicken the zero contour.
+zc = CS.collections[6]
+plt.setp(zc, linewidth=4)
+
+plt.clabel(CS, levels[1::2], # label every second level
+ inline=1,
+ fmt='%1.1f',
+ fontsize=14)
+
+# make a colorbar for the contour lines
+CB = plt.colorbar(CS, shrink=0.8, extend='both')
+
+plt.title('Lines with colorbar')
+#plt.hot() # Now change the colormap for the contour lines and colorbar
+plt.flag()
+
+# We can still add a colorbar for the image, too.
+CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
+
+# This makes the original colorbar look a bit out of place,
+# so let's improve its position.
+
+l,b,w,h = plt.gca().get_position().bounds
+ll,bb,ww,hh = CB.ax.get_position().bounds
+CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
+
+
+#savefig('contour_demo')
+plt.show()
Added: trunk/matplotlib/doc/pyplots/csd_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/csd_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/csd_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+"""
+Compute the cross spectral density of two signals
+"""
+import numpy as np
+import matplotlib.pyplot as plt
+
+# make a little extra space between the subplots
+plt.subplots_adjust(wspace=0.5)
+
+dt = 0.01
+t = np.arange(0, 30, dt)
+nse1 = np.random.randn(len(t)) # white noise 1
+nse2 = np.random.randn(len(t)) # white noise 2
+r = np.exp(-t/0.05)
+
+cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1
+cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2
+
+# two signals with a coherent part and a random part
+s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1
+s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2
+
+plt.subplot(211)
+plt.plot(t, s1, 'b-', t, s2, 'g-')
+plt.xlim(0,5)
+plt.xlabel('time')
+plt.ylabel('s1 and s2')
+plt.grid(True)
+
+plt.subplot(212)
+cxy, f = plt.csd(s1, s2, 256, 1./dt)
+plt.ylabel('CSD (db)')
+plt.show()
+
+
Added: trunk/matplotlib/doc/pyplots/errorbar_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/errorbar_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/errorbar_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,8 @@
+import numpy as np
+import matplotlib.pyplot as plt
+
+t = np.arange(0.1, 4, 0.1)
+s = np.exp(-t)
+e, f = 0.1*np.absolute(np.random.randn(2, len(s)))
+plt.errorbar(t, s, e, fmt='o') # vertical symmetric
+plt.show()
Added: trunk/matplotlib/doc/pyplots/figimage_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/figimage_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/figimage_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,21 @@
+"""
+See pcolor_demo2 for a much faster way of generating pcolor plots
+"""
+import numpy as np
+import matplotlib
+import matplotlib.cm as cm
+import matplotlib.pyplot as plt
+
+
+fig = plt.figure(frameon=False)
+Z = np.arange(10000.0)
+Z.shape = 100,100
+Z[:,50:] = 1.
+
+im1 = plt.figimage(Z, xo=50, yo=0, cmap=cm.jet)
+im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, cmap=cm.jet)
+
+plt.show()
+
+
+
Added: trunk/matplotlib/doc/pyplots/figlegend_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/figlegend_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/figlegend_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,19 @@
+import numpy as np
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+ax1 = fig.add_axes([0.1, 0.1, 0.4, 0.7])
+ax2 = fig.add_axes([0.55, 0.1, 0.4, 0.7])
+
+x = np.arange(0.0, 2.0, 0.02)
+y1 = np.sin(2*np.pi*x)
+y2 = np.exp(-x)
+l1, l2 = ax1.plot(x, y1, 'rs-', x, y2, 'go')
+
+y3 = np.sin(4*np.pi*x)
+y4 = np.exp(-2*x)
+l3, l4 = ax2.plot(x, y3, 'yd-', x, y3, 'k^')
+
+fig.legend((l1, l2), ('Line 1', 'Line 2'), 'upper left')
+fig.legend((l3, l4), ('Line 3', 'Line 4'), 'upper right')
+plt.show()
Added: trunk/matplotlib/doc/pyplots/fill_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/fill_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/fill_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+import numpy as np
+import matplotlib.pyplot as plt
+
+t = np.arange(0.0, 1.01, 0.01)
+s = np.sin(2*2*np.pi*t)
+
+plt.fill(t, s*np.exp(-5*t), 'r')
+plt.grid(True)
+plt.show()
Added: trunk/matplotlib/doc/pyplots/hexbin_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/hexbin_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/hexbin_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -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'.
+"""
+
+import numpy as np
+import matplotlib.pyplot as plt
+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()
+
+plt.subplots_adjust(hspace=0.5)
+plt.subplot(121)
+plt.hexbin(x,y)
+plt.axis([xmin, xmax, ymin, ymax])
+plt.title("Hexagon binning")
+cb = plt.colorbar()
+cb.set_label('counts')
+
+plt.subplot(122)
+plt.hexbin(x,y,bins='log')
+plt.axis([xmin, xmax, ymin, ymax])
+plt.title("With a log color scale")
+cb = plt.colorbar()
+cb.set_label('log10(N)')
+
+plt.show()
+
Added: trunk/matplotlib/doc/pyplots/histogram_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/histogram_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/histogram_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+import numpy as np
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
+
+mu, sigma = 100, 15
+x = mu + sigma*np.random.randn(10000)
+
+# the histogram of the data
+n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75)
+
+# add a 'best fit' line
+y = mlab.normpdf( bins, mu, sigma)
+l = plt.plot(bins, y, 'r--', linewidth=1)
+
+plt.xlabel('Smarts')
+plt.ylabel('Probability')
+plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
+plt.axis([40, 160, 0, 0.03])
+plt.grid(True)
+
+plt.show()
Added: trunk/matplotlib/doc/pyplots/hline_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/hline_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/hline_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+import numpy as np
+import matplotlib.pyplot as plt
+
+def f(t):
+ s1 = np.sin(2*np.pi*t)
+ e1 = np.exp(-t)
+ return np.absolute((s1*e1))+.05
+
+
+t = np.arange(0.0, 5.0, 0.1)
+s = f(t)
+nse = np.random.normal(0.0, 0.3, t.shape) * s
+
+
+plt.plot(s+nse, t, 'b^')
+plt.hlines(t, [0], s, lw=2)
+plt.xlabel('time (s)')
+plt.title('Comparison of model with data')
+plt.savefig('test')
+plt.xlim(xmin=0)
+plt.show()
+
Added: trunk/matplotlib/doc/pyplots/image_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/image_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/image_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+import numpy as np
+import matplotlib.cm as cm
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
+
+delta = 0.025
+x = y = np.arange(-3.0, 3.0, delta)
+X, Y = np.meshgrid(x, y)
+Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
+Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
+Z = Z2-Z1 # difference of Gaussians
+
+im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
+ origin='lower', extent=[-3,3,-3,3])
+
+plt.show()
+
Added: trunk/matplotlib/doc/pyplots/log_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/log_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/log_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,25 @@
+import numpy as np
+import matplotlib.pyplot as plt
+
+plt.subplots_adjust(hspace=0.4)
+t = np.arange(0.01, 20.0, 0.01)
+
+# log y axis
+plt.subplot(311)
+plt.semilogy(t, np.exp(-t/5.0))
+plt.ylabel('semilogy')
+plt.grid(True)
+
+# log x axis
+plt.subplot(312)
+plt.semilogx(t, np.sin(2*np.pi*t))
+plt.ylabel('semilogx')
+plt.grid(True)
+
+# log x and y axis
+plt.subplot(313)
+plt.loglog(t, 20*np.exp(-t/10.0), basex=4)
+plt.grid(True)
+plt.ylabel('loglog base 4 on x')
+
+plt.show()
Added: trunk/matplotlib/doc/pyplots/xcorr_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/xcorr_demo.py (rev 0)
+++ trunk/matplotlib/doc/pyplots/xcorr_demo.py 2008-06-27 15:34:32 UTC (rev 5690)
@@ -0,0 +1,17 @@
+import matplotlib.pyplot as plt
+import numpy as np
+
+x,y = np.random.randn(2,100)
+fig = plt.figure()
+ax1 = fig.add_subplot(211)
+ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2)
+ax1.grid(True)
+ax1.axhline(0, color='black', lw=2)
+
+ax2 = fig.add_subplot(212, sharex=ax1)
+ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2)
+ax2.grid(True)
+ax2.axhline(0, color='black', lw=2)
+
+plt.show()
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-27 15:42:47
|
Revision: 5693
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5693&view=rev
Author: jdh2358
Date: 2008-06-27 08:42:44 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
cleaned up some pyplots examples that got funkily duplicated
Modified Paths:
--------------
trunk/matplotlib/doc/pyplots/boxplot_demo.py
trunk/matplotlib/doc/pyplots/contour_demo.py
Modified: trunk/matplotlib/doc/pyplots/boxplot_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/boxplot_demo.py 2008-06-27 15:40:06 UTC (rev 5692)
+++ trunk/matplotlib/doc/pyplots/boxplot_demo.py 2008-06-27 15:42:44 UTC (rev 5693)
@@ -27,119 +27,3 @@
plt.boxplot(data)
plt.show()
-import numpy as np
-import matplotlib.pyplot as plt
-
-spread = np.random.rand(50) * 100
-center = np.ones(25) * 50
-flier_high = np.random.rand(10) * 100 + 100
-flier_low = np.random.rand(10) * -100
-data = np.concatenate((spread, center, flier_high, flier_low), 0)
-
-# fake up some more data
-spread = np.random.rand(50) * 100
-center = np.ones(25) * 40
-flier_high = np.random.rand(10) * 100 + 100
-flier_low = np.random.rand(10) * -100
-d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
-data.shape = (-1, 1)
-d2.shape = (-1, 1)
-
-#data = concatenate( (data, d2), 1 )
-# Making a 2-D array only works if all the columns are the
-# same length. If they are not, then use a list instead.
-# This is actually more efficient because boxplot converts
-# a 2-D array into a list of vectors internally anyway.
-data = [data, d2, d2[::2,0]]
-# multiple box plots on one figure
-
-plt.boxplot(data)
-plt.show()
-
-import numpy as np
-import matplotlib.pyplot as plt
-
-spread = np.random.rand(50) * 100
-center = np.ones(25) * 50
-flier_high = np.random.rand(10) * 100 + 100
-flier_low = np.random.rand(10) * -100
-data = np.concatenate((spread, center, flier_high, flier_low), 0)
-
-# fake up some more data
-spread = np.random.rand(50) * 100
-center = np.ones(25) * 40
-flier_high = np.random.rand(10) * 100 + 100
-flier_low = np.random.rand(10) * -100
-d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
-data.shape = (-1, 1)
-d2.shape = (-1, 1)
-
-#data = concatenate( (data, d2), 1 )
-# Making a 2-D array only works if all the columns are the
-# same length. If they are not, then use a list instead.
-# This is actually more efficient because boxplot converts
-# a 2-D array into a list of vectors internally anyway.
-data = [data, d2, d2[::2,0]]
-# multiple box plots on one figure
-
-plt.boxplot(data)
-plt.show()
-
-import numpy as np
-import matplotlib.pyplot as plt
-
-spread = np.random.rand(50) * 100
-center = np.ones(25) * 50
-flier_high = np.random.rand(10) * 100 + 100
-flier_low = np.random.rand(10) * -100
-data = np.concatenate((spread, center, flier_high, flier_low), 0)
-
-# fake up some more data
-spread = np.random.rand(50) * 100
-center = np.ones(25) * 40
-flier_high = np.random.rand(10) * 100 + 100
-flier_low = np.random.rand(10) * -100
-d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
-data.shape = (-1, 1)
-d2.shape = (-1, 1)
-
-#data = concatenate( (data, d2), 1 )
-# Making a 2-D array only works if all the columns are the
-# same length. If they are not, then use a list instead.
-# This is actually more efficient because boxplot converts
-# a 2-D array into a list of vectors internally anyway.
-data = [data, d2, d2[::2,0]]
-# multiple box plots on one figure
-
-plt.boxplot(data)
-plt.show()
-
-import numpy as np
-import matplotlib.pyplot as plt
-
-spread = np.random.rand(50) * 100
-center = np.ones(25) * 50
-flier_high = np.random.rand(10) * 100 + 100
-flier_low = np.random.rand(10) * -100
-data = np.concatenate((spread, center, flier_high, flier_low), 0)
-
-# fake up some more data
-spread = np.random.rand(50) * 100
-center = np.ones(25) * 40
-flier_high = np.random.rand(10) * 100 + 100
-flier_low = np.random.rand(10) * -100
-d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
-data.shape = (-1, 1)
-d2.shape = (-1, 1)
-
-#data = concatenate( (data, d2), 1 )
-# Making a 2-D array only works if all the columns are the
-# same length. If they are not, then use a list instead.
-# This is actually more efficient because boxplot converts
-# a 2-D array into a list of vectors internally anyway.
-data = [data, d2, d2[::2,0]]
-# multiple box plots on one figure
-
-plt.boxplot(data)
-plt.show()
-
Modified: trunk/matplotlib/doc/pyplots/contour_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/contour_demo.py 2008-06-27 15:40:06 UTC (rev 5692)
+++ trunk/matplotlib/doc/pyplots/contour_demo.py 2008-06-27 15:42:44 UTC (rev 5693)
@@ -64,267 +64,3 @@
#savefig('contour_demo')
plt.show()
-#!/usr/bin/env python
-"""
-Illustrate simple contour plotting, contours on an image with
-a colorbar for the contours, and labelled contours.
-
-See also contour_image.py.
-"""
-import matplotlib
-import numpy as np
-import matplotlib.cm as cm
-import matplotlib.mlab as mlab
-import matplotlib.pyplot as plt
-
-matplotlib.rcParams['xtick.direction'] = 'out'
-matplotlib.rcParams['ytick.direction'] = 'out'
-
-delta = 0.025
-x = np.arange(-3.0, 3.0, delta)
-y = np.arange(-2.0, 2.0, delta)
-X, Y = np.meshgrid(x, y)
-Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
-Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
-# difference of Gaussians
-Z = 10.0 * (Z2 - Z1)
-
-
-# You can use a colormap to specify the colors; the default
-# colormap will be used for the contour lines
-plt.figure()
-im = plt.imshow(Z, interpolation='bilinear', origin='lower',
- cmap=cm.gray, extent=(-3,3,-2,2))
-levels = np.arange(-1.2, 1.6, 0.2)
-CS = plt.contour(Z, levels,
- origin='lower',
- linewidths=2,
- extent=(-3,3,-2,2))
-
-#Thicken the zero contour.
-zc = CS.collections[6]
-plt.setp(zc, linewidth=4)
-
-plt.clabel(CS, levels[1::2], # label every second level
- inline=1,
- fmt='%1.1f',
- fontsize=14)
-
-# make a colorbar for the contour lines
-CB = plt.colorbar(CS, shrink=0.8, extend='both')
-
-plt.title('Lines with colorbar')
-#plt.hot() # Now change the colormap for the contour lines and colorbar
-plt.flag()
-
-# We can still add a colorbar for the image, too.
-CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
-
-# This makes the original colorbar look a bit out of place,
-# so let's improve its position.
-
-l,b,w,h = plt.gca().get_position().bounds
-ll,bb,ww,hh = CB.ax.get_position().bounds
-CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
-
-
-#savefig('contour_demo')
-plt.show()
-#!/usr/bin/env python
-"""
-Illustrate simple contour plotting, contours on an image with
-a colorbar for the contours, and labelled contours.
-
-See also contour_image.py.
-"""
-import matplotlib
-import numpy as np
-import matplotlib.cm as cm
-import matplotlib.mlab as mlab
-import matplotlib.pyplot as plt
-
-matplotlib.rcParams['xtick.direction'] = 'out'
-matplotlib.rcParams['ytick.direction'] = 'out'
-
-delta = 0.025
-x = np.arange(-3.0, 3.0, delta)
-y = np.arange(-2.0, 2.0, delta)
-X, Y = np.meshgrid(x, y)
-Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
-Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
-# difference of Gaussians
-Z = 10.0 * (Z2 - Z1)
-
-
-# You can use a colormap to specify the colors; the default
-# colormap will be used for the contour lines
-plt.figure()
-im = plt.imshow(Z, interpolation='bilinear', origin='lower',
- cmap=cm.gray, extent=(-3,3,-2,2))
-levels = np.arange(-1.2, 1.6, 0.2)
-CS = plt.contour(Z, levels,
- origin='lower',
- linewidths=2,
- extent=(-3,3,-2,2))
-
-#Thicken the zero contour.
-zc = CS.collections[6]
-plt.setp(zc, linewidth=4)
-
-plt.clabel(CS, levels[1::2], # label every second level
- inline=1,
- fmt='%1.1f',
- fontsize=14)
-
-# make a colorbar for the contour lines
-CB = plt.colorbar(CS, shrink=0.8, extend='both')
-
-plt.title('Lines with colorbar')
-#plt.hot() # Now change the colormap for the contour lines and colorbar
-plt.flag()
-
-# We can still add a colorbar for the image, too.
-CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
-
-# This makes the original colorbar look a bit out of place,
-# so let's improve its position.
-
-l,b,w,h = plt.gca().get_position().bounds
-ll,bb,ww,hh = CB.ax.get_position().bounds
-CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
-
-
-#savefig('contour_demo')
-plt.show()
-#!/usr/bin/env python
-"""
-Illustrate simple contour plotting, contours on an image with
-a colorbar for the contours, and labelled contours.
-
-See also contour_image.py.
-"""
-import matplotlib
-import numpy as np
-import matplotlib.cm as cm
-import matplotlib.mlab as mlab
-import matplotlib.pyplot as plt
-
-matplotlib.rcParams['xtick.direction'] = 'out'
-matplotlib.rcParams['ytick.direction'] = 'out'
-
-delta = 0.025
-x = np.arange(-3.0, 3.0, delta)
-y = np.arange(-2.0, 2.0, delta)
-X, Y = np.meshgrid(x, y)
-Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
-Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
-# difference of Gaussians
-Z = 10.0 * (Z2 - Z1)
-
-
-# You can use a colormap to specify the colors; the default
-# colormap will be used for the contour lines
-plt.figure()
-im = plt.imshow(Z, interpolation='bilinear', origin='lower',
- cmap=cm.gray, extent=(-3,3,-2,2))
-levels = np.arange(-1.2, 1.6, 0.2)
-CS = plt.contour(Z, levels,
- origin='lower',
- linewidths=2,
- extent=(-3,3,-2,2))
-
-#Thicken the zero contour.
-zc = CS.collections[6]
-plt.setp(zc, linewidth=4)
-
-plt.clabel(CS, levels[1::2], # label every second level
- inline=1,
- fmt='%1.1f',
- fontsize=14)
-
-# make a colorbar for the contour lines
-CB = plt.colorbar(CS, shrink=0.8, extend='both')
-
-plt.title('Lines with colorbar')
-#plt.hot() # Now change the colormap for the contour lines and colorbar
-plt.flag()
-
-# We can still add a colorbar for the image, too.
-CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
-
-# This makes the original colorbar look a bit out of place,
-# so let's improve its position.
-
-l,b,w,h = plt.gca().get_position().bounds
-ll,bb,ww,hh = CB.ax.get_position().bounds
-CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
-
-
-#savefig('contour_demo')
-plt.show()
-#!/usr/bin/env python
-"""
-Illustrate simple contour plotting, contours on an image with
-a colorbar for the contours, and labelled contours.
-
-See also contour_image.py.
-"""
-import matplotlib
-import numpy as np
-import matplotlib.cm as cm
-import matplotlib.mlab as mlab
-import matplotlib.pyplot as plt
-
-matplotlib.rcParams['xtick.direction'] = 'out'
-matplotlib.rcParams['ytick.direction'] = 'out'
-
-delta = 0.025
-x = np.arange(-3.0, 3.0, delta)
-y = np.arange(-2.0, 2.0, delta)
-X, Y = np.meshgrid(x, y)
-Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
-Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
-# difference of Gaussians
-Z = 10.0 * (Z2 - Z1)
-
-
-# You can use a colormap to specify the colors; the default
-# colormap will be used for the contour lines
-plt.figure()
-im = plt.imshow(Z, interpolation='bilinear', origin='lower',
- cmap=cm.gray, extent=(-3,3,-2,2))
-levels = np.arange(-1.2, 1.6, 0.2)
-CS = plt.contour(Z, levels,
- origin='lower',
- linewidths=2,
- extent=(-3,3,-2,2))
-
-#Thicken the zero contour.
-zc = CS.collections[6]
-plt.setp(zc, linewidth=4)
-
-plt.clabel(CS, levels[1::2], # label every second level
- inline=1,
- fmt='%1.1f',
- fontsize=14)
-
-# make a colorbar for the contour lines
-CB = plt.colorbar(CS, shrink=0.8, extend='both')
-
-plt.title('Lines with colorbar')
-#plt.hot() # Now change the colormap for the contour lines and colorbar
-plt.flag()
-
-# We can still add a colorbar for the image, too.
-CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
-
-# This makes the original colorbar look a bit out of place,
-# so let's improve its position.
-
-l,b,w,h = plt.gca().get_position().bounds
-ll,bb,ww,hh = CB.ax.get_position().bounds
-CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
-
-
-#savefig('contour_demo')
-plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-27 15:42:23
|
Revision: 5692
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5692&view=rev
Author: jdh2358
Date: 2008-06-27 08:40:06 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
removing the copied files I accidentally added (sigh). It is confusing to put autogenerated files next to legit files in pyplot...
Removed Paths:
-------------
trunk/matplotlib/doc/pyplots/hline_demo.py
Deleted: trunk/matplotlib/doc/pyplots/hline_demo.py
===================================================================
--- trunk/matplotlib/doc/pyplots/hline_demo.py 2008-06-27 15:39:28 UTC (rev 5691)
+++ trunk/matplotlib/doc/pyplots/hline_demo.py 2008-06-27 15:40:06 UTC (rev 5692)
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-import numpy as np
-import matplotlib.pyplot as plt
-
-def f(t):
- s1 = np.sin(2*np.pi*t)
- e1 = np.exp(-t)
- return np.absolute((s1*e1))+.05
-
-
-t = np.arange(0.0, 5.0, 0.1)
-s = f(t)
-nse = np.random.normal(0.0, 0.3, t.shape) * s
-
-
-plt.plot(s+nse, t, 'b^')
-plt.hlines(t, [0], s, lw=2)
-plt.xlabel('time (s)')
-plt.title('Comparison of model with data')
-plt.savefig('test')
-plt.xlim(xmin=0)
-plt.show()
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-27 15:26:05
|
Revision: 5688
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5688&view=rev
Author: jdh2358
Date: 2008-06-27 08:25:50 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
more doc examples and cleanups
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/axhspan_demo.py
trunk/matplotlib/examples/pylab_examples/barchart_demo.py
trunk/matplotlib/examples/pylab_examples/contour_demo.py
trunk/matplotlib/examples/pylab_examples/figimage_demo.py
trunk/matplotlib/examples/pylab_examples/figlegend_demo.py
trunk/matplotlib/examples/pylab_examples/log_demo.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/contour.py
trunk/matplotlib/lib/matplotlib/figure.py
Modified: trunk/matplotlib/examples/pylab_examples/axhspan_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/axhspan_demo.py 2008-06-27 13:33:33 UTC (rev 5687)
+++ trunk/matplotlib/examples/pylab_examples/axhspan_demo.py 2008-06-27 15:25:50 UTC (rev 5688)
@@ -1,40 +1,32 @@
-#!/usr/bin/env python
+import numpy as np
+import matplotlib.pyplot as plt
-from pylab import *
-figure(1)
-plot(10*rand(12), 'o')
-xlim(0,15)
-xticks([2, 4, 8, 12], ('John', 'Hunter', 'Was', 'Here'))
+t = np.arange(-1,2, .01)
+s = np.sin(2*np.pi*t)
-ylim(-1,10)
-yticks(range(8))
-
-figure(2)
-t = arange(-1,2, .01)
-s = sin(2*pi*t)
-plot(t,s)
+plt.plot(t,s)
# draw a thick red hline at y=0 that spans the xrange
-l = axhline(linewidth=4, color='r')
+l = plt.axhline(linewidth=4, color='r')
# draw a default hline at y=1 that spans the xrange
-l = axhline(y=1)
+l = plt.axhline(y=1)
# draw a default vline at x=1 that spans the xrange
-l = axvline(x=1)
+l = plt.axvline(x=1)
# draw a thick blue vline at x=0 that spans the the upper quadrant of
# the yrange
-l = axvline(x=0, ymin=0.75, linewidth=4, color='b')
+l = plt.axvline(x=0, ymin=0.75, linewidth=4, color='b')
# draw a default hline at y=.5 that spans the the middle half of
# the axes
-l = axhline(y=.5, xmin=0.25, xmax=0.75)
+l = plt.axhline(y=.5, xmin=0.25, xmax=0.75)
-p = axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
+p = plt.axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
-p = axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
+p = plt.axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
-axis([-1,2,-1,2])
+plt.axis([-1,2,-1,2])
-show()
+plt.show()
Modified: trunk/matplotlib/examples/pylab_examples/barchart_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/barchart_demo.py 2008-06-27 13:33:33 UTC (rev 5687)
+++ trunk/matplotlib/examples/pylab_examples/barchart_demo.py 2008-06-27 15:25:50 UTC (rev 5688)
@@ -1,39 +1,38 @@
#!/usr/bin/env python
-# a bar plot with errorbars
-from numpy import arange
-from matplotlib.pyplot 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
-figure()
-subplot(111)
-rects1 = bar(ind, menMeans, width, color='r', yerr=menStd)
+plt.subplot(111)
+rects1 = plt.bar(ind, menMeans, width, color='r', yerr=menStd)
+
womenMeans = (25, 32, 34, 20, 25)
womenStd = (3, 5, 2, 3, 3)
-rects2 = bar(ind+width, womenMeans, width, color='y', yerr=womenStd)
+rects2 = plt.bar(ind+width, womenMeans, width, color='y', yerr=womenStd)
# add some
-ylabel('Scores')
-title('Scores by group and gender')
-xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5') )
+plt.ylabel('Scores')
+plt.title('Scores by group and gender')
+plt.xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5') )
-legend( (rects1[0], rects2[0]), ('Men', 'Women') )
+plt.legend( (rects1[0], rects2[0]), ('Men', 'Women') )
def autolabel(rects):
# attach some text labels
for rect in rects:
height = rect.get_height()
- text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height),
+ plt.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height),
ha='center', va='bottom')
autolabel(rects1)
autolabel(rects2)
#savefig('barchart_demo')
-show()
+plt.show()
Modified: trunk/matplotlib/examples/pylab_examples/contour_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/contour_demo.py 2008-06-27 13:33:33 UTC (rev 5687)
+++ trunk/matplotlib/examples/pylab_examples/contour_demo.py 2008-06-27 15:25:50 UTC (rev 5688)
@@ -1,21 +1,25 @@
#!/usr/bin/env python
-'''
+"""
Illustrate simple contour plotting, contours on an image with
a colorbar for the contours, and labelled contours.
See also contour_image.py.
-'''
-from pylab import *
+"""
+import matplotlib
+import numpy as np
+import matplotlib.cm as cm
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
-rcParams['xtick.direction'] = 'out'
-rcParams['ytick.direction'] = 'out'
+matplotlib.rcParams['xtick.direction'] = 'out'
+matplotlib.rcParams['ytick.direction'] = 'out'
delta = 0.025
-x = arange(-3.0, 3.0, delta)
-y = arange(-2.0, 2.0, delta)
-X, Y = 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)
+x = np.arange(-3.0, 3.0, delta)
+y = np.arange(-2.0, 2.0, delta)
+X, Y = np.meshgrid(x, y)
+Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
+Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
# difference of Gaussians
Z = 10.0 * (Z2 - Z1)
@@ -25,77 +29,77 @@
# inline argument to clabel will control whether the labels are draw
# over the line segments of the contour, removing the lines beneath
# the label
-figure()
-CS = contour(X, Y, Z)
-clabel(CS, inline=1, fontsize=10)
-title('Simplest default with labels')
+plt.figure()
+CS = plt.contour(X, Y, Z)
+plt.clabel(CS, inline=1, fontsize=10)
+plt.title('Simplest default with labels')
# You can force all the contours to be the same color.
-figure()
-CS = contour(X, Y, Z, 6,
- colors='k', # negative contours will be dashed by default
- )
-clabel(CS, fontsize=9, inline=1)
-title('Single color - negative contours dashed')
+plt.figure()
+CS = plt.contour(X, Y, Z, 6,
+ colors='k', # negative contours will be dashed by default
+ )
+plt.clabel(CS, fontsize=9, inline=1)
+plt.title('Single color - negative contours dashed')
# You can set negative contours to be solid instead of dashed:
-rcParams['contour.negative_linestyle'] = 'solid'
-figure()
-CS = contour(X, Y, Z, 6,
- colors='k', # negative contours will be dashed by default
- )
-clabel(CS, fontsize=9, inline=1)
-title('Single color - negative contours solid')
+matplotlib.rcParams['contour.negative_linestyle'] = 'solid'
+plt.figure()
+CS = plt.contour(X, Y, Z, 6,
+ colors='k', # negative contours will be dashed by default
+ )
+plt.clabel(CS, fontsize=9, inline=1)
+plt.title('Single color - negative contours solid')
# And you can manually specify the colors of the contour
-figure()
-CS = contour(X, Y, Z, 6,
- linewidths=arange(.5, 4, .5),
- colors=('r', 'green', 'blue', (1,1,0), '#afeeee', '0.5')
- )
-clabel(CS, fontsize=9, inline=1)
-title('Crazy lines')
+plt.figure()
+CS = plt.contour(X, Y, Z, 6,
+ linewidths=np.arange(.5, 4, .5),
+ colors=('r', 'green', 'blue', (1,1,0), '#afeeee', '0.5')
+ )
+plt.clabel(CS, fontsize=9, inline=1)
+plt.title('Crazy lines')
# Or you can use a colormap to specify the colors; the default
# colormap will be used for the contour lines
-figure()
-im = imshow(Z, interpolation='bilinear', origin='lower',
- cmap=cm.gray, extent=(-3,3,-2,2))
-levels = arange(-1.2, 1.6, 0.2)
-CS = contour(Z, levels,
- origin='lower',
- linewidths=2,
- extent=(-3,3,-2,2))
+plt.figure()
+im = plt.imshow(Z, interpolation='bilinear', origin='lower',
+ cmap=cm.gray, extent=(-3,3,-2,2))
+levels = np.arange(-1.2, 1.6, 0.2)
+CS = plt.contour(Z, levels,
+ origin='lower',
+ linewidths=2,
+ extent=(-3,3,-2,2))
#Thicken the zero contour.
zc = CS.collections[6]
-setp(zc, linewidth=4)
+plt.setp(zc, linewidth=4)
-clabel(CS, levels[1::2], # label every second level
- inline=1,
- fmt='%1.1f',
- fontsize=14)
+plt.clabel(CS, levels[1::2], # label every second level
+ inline=1,
+ fmt='%1.1f',
+ fontsize=14)
# make a colorbar for the contour lines
-CB = colorbar(CS, shrink=0.8, extend='both')
+CB = plt.colorbar(CS, shrink=0.8, extend='both')
-title('Lines with colorbar')
-hot() # Now change the colormap for the contour lines and colorbar
-flag()
+plt.title('Lines with colorbar')
+#plt.hot() # Now change the colormap for the contour lines and colorbar
+plt.flag()
# We can still add a colorbar for the image, too.
-CBI = colorbar(im, orientation='horizontal', shrink=0.8)
+CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
# This makes the original colorbar look a bit out of place,
# so let's improve its position.
-l,b,w,h = gca().get_position().bounds
+l,b,w,h = plt.gca().get_position().bounds
ll,bb,ww,hh = CB.ax.get_position().bounds
CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
#savefig('contour_demo')
-show()
+plt.show()
Modified: trunk/matplotlib/examples/pylab_examples/figimage_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008-06-27 13:33:33 UTC (rev 5687)
+++ trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008-06-27 15:25:50 UTC (rev 5688)
@@ -1,21 +1,21 @@
-#!/usr/bin/env python
"""
See pcolor_demo2 for a much faster way of generating pcolor plots
"""
-from __future__ import division
-from pylab import *
-rc('axes', hold=True)
-rc('image', origin='upper')
-figure(1, frameon=False)
-Z = arange(10000.0); Z.shape = 100,100
-Z[:,50:] = 1
-jet() # sets the default
-im1 = figimage(Z, xo=50, yo=0)
-im2 = figimage(Z, xo=100, yo=100, alpha=.8)
-#gray() # overrides current and sets default
-#savefig('figimage_demo')
+import numpy as np
+import matplotlib
+import matplotlib.cm as cm
+import matplotlib.pyplot as plt
-show()
+fig = plt.figure(frameon=False)
+Z = np.arange(10000.0)
+Z.shape = 100,100
+Z[:,50:] = 1.
+im1 = plt.figimage(Z, xo=50, yo=0, cmap=cm.jet)
+im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, cmap=cm.jet)
+plt.show()
+
+
+
Modified: trunk/matplotlib/examples/pylab_examples/figlegend_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/figlegend_demo.py 2008-06-27 13:33:33 UTC (rev 5687)
+++ trunk/matplotlib/examples/pylab_examples/figlegend_demo.py 2008-06-27 15:25:50 UTC (rev 5688)
@@ -1,18 +1,19 @@
-#!/usr/bin/env python
+import numpy as np
+import matplotlib.pyplot as plt
-from pylab import *
-ax1 = axes([0.1, 0.1, 0.4, 0.7])
-ax2 = axes([0.55, 0.1, 0.4, 0.7])
+fig = plt.figure()
+ax1 = fig.add_axes([0.1, 0.1, 0.4, 0.7])
+ax2 = fig.add_axes([0.55, 0.1, 0.4, 0.7])
-x = arange(0.0, 2.0, 0.02)
-y1 = sin(2*pi*x)
-y2 = exp(-x)
+x = np.arange(0.0, 2.0, 0.02)
+y1 = np.sin(2*np.pi*x)
+y2 = np.exp(-x)
l1, l2 = ax1.plot(x, y1, 'rs-', x, y2, 'go')
-y3 = sin(4*pi*x)
-y4 = exp(-2*x)
+y3 = np.sin(4*np.pi*x)
+y4 = np.exp(-2*x)
l3, l4 = ax2.plot(x, y3, 'yd-', x, y3, 'k^')
-figlegend((l1, l2), ('Line 1', 'Line 2'), 'upper left')
-figlegend((l3, l4), ('Line 3', 'Line 4'), 'upper right')
-show()
+fig.legend((l1, l2), ('Line 1', 'Line 2'), 'upper left')
+fig.legend((l3, l4), ('Line 3', 'Line 4'), 'upper right')
+plt.show()
Modified: trunk/matplotlib/examples/pylab_examples/log_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/log_demo.py 2008-06-27 13:33:33 UTC (rev 5687)
+++ trunk/matplotlib/examples/pylab_examples/log_demo.py 2008-06-27 15:25:50 UTC (rev 5688)
@@ -1,26 +1,25 @@
-#!/usr/bin/env python
-from pylab import *
+import numpy as np
+import matplotlib.pyplot as plt
-dt = 0.01
-t = arange(dt, 20.0, dt)
+plt.subplots_adjust(hspace=0.4)
+t = np.arange(0.01, 20.0, 0.01)
-subplot(311)
-semilogy(t, exp(-t/5.0))
-ylabel('semilogy')
-grid(True)
+# log y axis
+plt.subplot(311)
+plt.semilogy(t, np.exp(-t/5.0))
+plt.ylabel('semilogy')
+plt.grid(True)
-subplot(312)
-semilogx(t, sin(2*pi*t))
-ylabel('semilogx')
+# log x axis
+plt.subplot(312)
+plt.semilogx(t, np.sin(2*np.pi*t))
+plt.ylabel('semilogx')
+plt.grid(True)
+# log x and y axis
+plt.subplot(313)
+plt.loglog(t, 20*np.exp(-t/10.0), basex=4)
+plt.grid(True)
+plt.ylabel('loglog base 4 on x')
-
-grid(True)
-gca().xaxis.grid(True, which='minor') # minor grid on too
-
-subplot(313)
-loglog(t, 20*exp(-t/10.0), basex=4)
-grid(True)
-ylabel('loglog base 4 on x')
-savefig('log_demo')
-show()
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-27 13:33:33 UTC (rev 5687)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-27 15:25:50 UTC (rev 5688)
@@ -2697,6 +2697,8 @@
Valid kwargs are :class:`~matplotlib.lines.Line2D` properties:
%(Line2D)s
+
+ See :meth:`axhspan` for example plot and source code
"""
ymin, ymax = self.get_ylim()
@@ -2747,6 +2749,8 @@
Valid kwargs are :class:`~matplotlib.lines.Line2D` properties:
%(Line2D)s
+
+ See :meth:`axhspan` for example plot and source code
"""
xmin, xmax = self.get_xlim()
@@ -2793,6 +2797,11 @@
Valid kwargs are :class:`~matplotlib.patches.Polygon` properties:
%(Polygon)s
+
+ **Example:**
+
+ .. plot:: ../mpl_examples/pylab_examples/axhspan_demo.py
+
"""
# convert y axis units
trans = mtransforms.blended_transform_factory(
@@ -2836,6 +2845,8 @@
properties:
%(Polygon)s
+
+ See :meth:`axhspan` for example plot and source code
"""
# convert x axis units
trans = mtransforms.blended_transform_factory(
@@ -3214,6 +3225,11 @@
:class:`~matplotlib.lines.Line2D` properties:
%(Line2D)s
+
+ **Example:**
+
+ .. plot:: ../mpl_examples/pylab_examples/log_demo.py
+
"""
if not self._hold: self.cla()
@@ -3262,6 +3278,8 @@
:class:`~matplotlib.lines.Line2D` properties:
%(Line2D)s
+
+ See :meth:`loglog` for example code and figure
"""
if not self._hold: self.cla()
d = {'basex': kwargs.pop( 'basex', 10),
@@ -3303,6 +3321,8 @@
:class:`~matplotlib.lines.Line2D` properties:
%(Line2D)s
+
+ See :meth:`loglog` for example code and figure
"""
if not self._hold: self.cla()
d = {'basey': kwargs.pop('basey', 10),
@@ -3371,6 +3391,8 @@
:func:`~matplotlib.pyplot.xcorr` above, and
:func:`~matplotlib.pyplot.acorr` below.
+ **Example:**
+
.. plot:: ../mpl_examples/pylab_examples/xcorr_demo.py
"""
return self.xcorr(x, x, **kwargs)
@@ -3426,6 +3448,8 @@
:func:`~matplotlib.pyplot.xcorr` above, and
:func:`~matplotlib.pyplot.acorr` below.
+ **Example:**
+
.. plot:: ../mpl_examples/pylab_examples/xcorr_demo.py
"""
@@ -3565,6 +3589,10 @@
*axespad*: [ None | scalar ]
The border between the axes and legend edge. If *None*, use rc
settings.
+
+ **Example:**
+
+ .. plot:: legend_demo.py
"""
def get_handles():
@@ -3724,10 +3752,8 @@
%(Rectangle)s
- **Example:**
+ **Example:** A stacked bar chart.
- A stacked bar chart.
-
.. plot:: ../mpl_examples/pylab_examples/bar_stacked.py
"""
if not self._hold: self.cla()
@@ -4295,6 +4321,11 @@
the third element is a list of
:class:`~matplotlib.collections.LineCollection` instances for
the horizontal and vertical error ranges.
+
+ **Example:**
+
+ .. plot:: errorbar_demo.py
+
"""
self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
@@ -4496,6 +4527,9 @@
Returns a list of the :class:`matplotlib.lines.Line2D`
instances added.
+ **Example:**
+
+ .. plot:: boxplot_demo.py
"""
if not self._hold: self.cla()
holdStatus = self._hold
Modified: trunk/matplotlib/lib/matplotlib/contour.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/contour.py 2008-06-27 13:33:33 UTC (rev 5687)
+++ trunk/matplotlib/lib/matplotlib/contour.py 2008-06-27 15:25:50 UTC (rev 5688)
@@ -69,6 +69,7 @@
*fmt*:
a format string for the label. Default is '%1.3f'
+
"""
fontsize = kwargs.get('fontsize', None)
inline = kwargs.get('inline', 1)
@@ -892,4 +893,5 @@
be removed. Chunking introduces artifacts at the chunk boundaries
unless *antialiased* is *False*.
+ .. plot:: contour_demo.py
"""
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2008-06-27 13:33:33 UTC (rev 5687)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2008-06-27 15:25:50 UTC (rev 5688)
@@ -468,6 +468,9 @@
:class:`~matplotlib.axes.Axes` with size [0,1,0,1].
An :class:`matplotlib.image.FigureImage` instance is returned.
+
+ .. plot:: ../mpl_examples/pylab_examples/figimage_demo.py
+
"""
if not self._hold: self.clf()
@@ -912,6 +915,7 @@
*axespad*
the border between the axes and legend edge
+ .. plot:: ../mpl_examples/pylab_examples/figlegend_demo.py
"""
handles = flatten(handles)
l = Legend(self, handles, labels, *args, **kwargs)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-06-27 13:33:50
|
Revision: 5687
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5687&view=rev
Author: mdboom
Date: 2008-06-27 06:33:33 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
Add information about numpy copies. Add suggested replacement for offset_copy().
Modified Paths:
--------------
trunk/matplotlib/API_CHANGES
Modified: trunk/matplotlib/API_CHANGES
===================================================================
--- trunk/matplotlib/API_CHANGES 2008-06-27 13:31:53 UTC (rev 5686)
+++ trunk/matplotlib/API_CHANGES 2008-06-27 13:33:33 UTC (rev 5687)
@@ -55,6 +55,11 @@
See transforms.py for a description of the design of the new
transformation framework.
+ For efficiency, many of these functions return views into Numpy
+ arrays. This means that if you hold on to a reference to them,
+ their contents may change. If you want to store a snapshot of
+ their current values, use the Numpy array method copy().
+
The view intervals are now stored only in one place -- in the Axes
instance, not in the formatter instances as well. This means
formatters must get their limits from their Axis, which in turn
@@ -122,6 +127,8 @@
Transform.inverse_xy_tup(points) Transform.inverted().transform(points)
+ offset_copy(trans, x, y) trans + Affine2D().translate(x, y)
+
axes.py
Axes.get_position() Axes.get_position()
[Axes.get_position() used to return a list of points, not it
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|