SourceForge logo
SourceForge logo
Menu

matplotlib-checkins

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 (2008年6月27日)
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:51:55
Revision: 5690
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5690&view=rev
Author: jdh2358
Date: 2008年06月27日 08:34:32 -0700 (2008年6月27日)
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:53:17
Revision: 5691
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5691&view=rev
Author: jdh2358
Date: 2008年06月27日 08:39:28 -0700 (2008年6月27日)
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.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





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

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

More information about our ad policies

Ad destination/click URL:

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