Revision: 5884 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5884&view=rev Author: ryanmay Date: 2008年07月26日 00:34:02 +0000 (2008年7月26日) Log Message: ----------- Set svn:ignore on the subdirectories within examples (except data) Property Changed: ---------------- trunk/matplotlib/examples/animation/ trunk/matplotlib/examples/api/ trunk/matplotlib/examples/event_handling/ trunk/matplotlib/examples/misc/ trunk/matplotlib/examples/pylab_examples/ trunk/matplotlib/examples/tests/ trunk/matplotlib/examples/units/ trunk/matplotlib/examples/user_interfaces/ trunk/matplotlib/examples/widgets/ Property changes on: trunk/matplotlib/examples/animation ___________________________________________________________________ Added: svn:ignore + matplotlibrc matplotlib.conf *.eps *.jpeg *.jpg *.pdf *.png *.ps *.pyc *.svg Property changes on: trunk/matplotlib/examples/api ___________________________________________________________________ Added: svn:ignore + matplotlibrc matplotlib.conf *.eps *.jpeg *.jpg *.pdf *.png *.ps *.pyc *.svg Property changes on: trunk/matplotlib/examples/event_handling ___________________________________________________________________ Added: svn:ignore + matplotlibrc matplotlib.conf *.eps *.jpeg *.jpg *.pdf *.png *.ps *.pyc *.svg Property changes on: trunk/matplotlib/examples/misc ___________________________________________________________________ Added: svn:ignore + matplotlibrc matplotlib.conf *.eps *.jpeg *.jpg *.pdf *.png *.ps *.pyc *.svg Property changes on: trunk/matplotlib/examples/pylab_examples ___________________________________________________________________ Added: svn:ignore + matplotlibrc matplotlib.conf *.eps *.jpeg *.jpg *.pdf *.png *.ps *.pyc *.svg Property changes on: trunk/matplotlib/examples/tests ___________________________________________________________________ Added: svn:ignore + matplotlibrc matplotlib.conf *.eps *.jpeg *.jpg *.pdf *.png *.ps *.pyc *.svg Property changes on: trunk/matplotlib/examples/units ___________________________________________________________________ Added: svn:ignore + matplotlibrc matplotlib.conf *.eps *.jpeg *.jpg *.pdf *.png *.ps *.pyc *.svg Property changes on: trunk/matplotlib/examples/user_interfaces ___________________________________________________________________ Added: svn:ignore + matplotlibrc matplotlib.conf *.eps *.jpeg *.jpg *.pdf *.png *.ps *.pyc *.svg Property changes on: trunk/matplotlib/examples/widgets ___________________________________________________________________ Added: svn:ignore + matplotlibrc matplotlib.conf *.eps *.jpeg *.jpg *.pdf *.png *.ps *.pyc *.svg This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5895 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5895&view=rev Author: jdh2358 Date: 2008年07月26日 23:26:02 +0000 (2008年7月26日) Log Message: ----------- more broken example fixes Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/multi_image.py trunk/matplotlib/examples/tests/backend_driver.py Modified: trunk/matplotlib/examples/pylab_examples/multi_image.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/multi_image.py 2008年07月26日 23:11:54 UTC (rev 5894) +++ trunk/matplotlib/examples/pylab_examples/multi_image.py 2008年07月26日 23:26:02 UTC (rev 5895) @@ -50,17 +50,25 @@ # Set the first image as the master, with all the others # observing it for changes in cmap or norm. + +class ImageFollower: + 'update image in response to changes in clim or cmap on another image' + def __init__(self, follower): + self.follower = follower + def __call__(self, leader): + self.follower.set_cmap(leader.get_cmap()) + self.follower.set_clim(leader.get_clim()) + norm = colors.Normalize(vmin=vmin, vmax=vmax) for i, im in enumerate(images): im.set_norm(norm) if i > 0: - images[0].add_observer(im) + images[0].callbacksSM.connect('changed', ImageFollower(im)) # The colorbar is also based on this master image. fig.colorbar(images[0], cax, orientation='horizontal') # We need the following only if we want to run this -# script interactively and be able to change the colormap. sci(images[0]) Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年07月26日 23:11:54 UTC (rev 5894) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年07月26日 23:26:02 UTC (rev 5895) @@ -43,6 +43,7 @@ 'contour_demo.py', 'contour_label_demo.py', 'contourf_demo.py', + 'geo_demo.py', 'griddata_demo.py', 'csd_demo.py', 'custom_ticker1.py', @@ -80,6 +81,7 @@ 'mathtext_demo.py', 'mri_with_eeg.py', 'multiple_figs_demo.py', + 'multi_image.py', 'nan_test.py', 'pcolor_demo.py', 'pcolor_demo2.py', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5900 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5900&view=rev Author: jdh2358 Date: 2008年07月27日 04:47:42 +0000 (2008年7月27日) Log Message: ----------- commented out wide unicode line in stix example until we have a conditional check for wide char support Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py trunk/matplotlib/examples/tests/backend_driver.py Modified: trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py 2008年07月27日 02:11:05 UTC (rev 5899) +++ trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py 2008年07月27日 04:47:42 UTC (rev 5900) @@ -14,14 +14,14 @@ r'$\mathbf{\mathbb{Blackboard \pi}}$', r'$\mathfrak{Fraktur} \mathbf{\mathfrak{Fraktur}}$', r'$\mathscr{Script}$', - ur'Direct Unicode: $\u23ce \mathrm{\ue0f2 \U0001D538}$' +# ur'Direct Unicode: $\u23ce \mathrm{\ue0f2 \U0001D538}$' ] from pylab import * def doall(): tests = stests - + figure(figsize=(8, (len(tests) * 1) + 2)) plot([0, 0], 'r') grid(False) @@ -34,7 +34,7 @@ savefig('stix_fonts_example') #close('all') show() - + if '--latex' in sys.argv: fd = open("stix_fonts_examples.ltx", "w") fd.write("\\documentclass{article}\n") Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年07月27日 02:11:05 UTC (rev 5899) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年07月27日 04:47:42 UTC (rev 5900) @@ -102,9 +102,11 @@ 'spy_demos.py', 'stem_plot.py', 'step_demo.py', + 'stix_fonts_demo.py', 'stock_demo.py', 'subplot_demo.py', -# 'set_and_get.py', + 'symlog_demo.py', + # 'set_and_get.py', 'table_demo.py', 'text_handles.py', 'text_rotation.py', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5902 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5902&view=rev Author: jdh2358 Date: 2008年07月27日 05:13:23 +0000 (2008年7月27日) Log Message: ----------- added missing coverage report to backend driver Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/barcode_demo.py trunk/matplotlib/examples/tests/backend_driver.py Modified: trunk/matplotlib/examples/pylab_examples/barcode_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/barcode_demo.py 2008年07月27日 04:48:53 UTC (rev 5901) +++ trunk/matplotlib/examples/pylab_examples/barcode_demo.py 2008年07月27日 05:13:23 UTC (rev 5902) @@ -21,6 +21,6 @@ ax = fig.add_axes([0.3, 0.1, 0.6, 0.1], **axprops) ax.imshow(x, **barprops) -fig.savefig('barcode.png', dpi=100) +#fig.savefig('barcode.png', dpi=100) show() Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年07月27日 04:48:53 UTC (rev 5901) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年07月27日 05:13:23 UTC (rev 5902) @@ -59,6 +59,7 @@ 'finance_demo.py', 'fonts_demo_kw.py', 'hexbin_demo.py', + 'hexbin_demo2.py', 'histogram_demo.py', 'hline_demo.py', 'image_demo.py', @@ -139,6 +140,34 @@ ] +# dict from dir to files we know we don't want to test (eg examples +# not using pyplot, examples requiring user input, animation examples, +# examples that may only work in certain environs (usetex examples?), +# examples that generate multiple figures + +excluded = { + pylab_dir : ['__init__.py', 'toggle_images.py',], + units_dir : ['__init__.py', 'date_support.py',], +} + +def report_missing(dir, flist): + 'report the py files in dir that are not in flist' + globstr = os.path.join(dir, '*.py') + fnames = glob.glob(globstr) + + pyfiles = set([os.path.split(fullpath)[-1] for fullpath in set(fnames)]) + + exclude = set(excluded.get(dir, [])) + flist = set(flist) + missing = list(pyfiles-flist-exclude) + missing.sort() + print '%s files not tested: %s'%(dir, ', '.join(missing)) + + +report_missing(pylab_dir, pylab_files) +report_missing(api_dir, api_files) +report_missing(units_dir, units_files) + files = [os.path.join(pylab_dir, fname) for fname in pylab_files] +\ [os.path.join(api_dir, fname) for fname in api_files] +\ [os.path.join(units_dir, fname) for fname in units_files] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6059 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6059&view=rev Author: efiring Date: 2008年09月01日 22:27:07 +0000 (2008年9月01日) Log Message: ----------- Improve backend_driver error reporting. Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/image_nonuniform.py trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py trunk/matplotlib/examples/tests/backend_driver.py Modified: trunk/matplotlib/examples/pylab_examples/image_nonuniform.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/image_nonuniform.py 2008年09月01日 21:09:09 UTC (rev 6058) +++ trunk/matplotlib/examples/pylab_examples/image_nonuniform.py 2008年09月01日 22:27:07 UTC (rev 6059) @@ -13,7 +13,7 @@ x = np.linspace(-4, 4, 9) x2 = x**3 y = np.linspace(-4, 4, 9) -print 'Size %d points' % (len(x) * len(y)) +#print 'Size %d points' % (len(x) * len(y)) z = np.sqrt(x[np.newaxis,:]**2 + y[:,np.newaxis]**2) fig = figure() Modified: trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py 2008年09月01日 21:09:09 UTC (rev 6058) +++ trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py 2008年09月01日 22:27:07 UTC (rev 6059) @@ -31,7 +31,7 @@ axis([0, 3, -len(tests), 0]) yticks(arange(len(tests)) * -1) for i, s in enumerate(tests): - print (i, s.encode("ascii", "backslashreplace")) + #print (i, s.encode("ascii", "backslashreplace")) text(0.1, -i, s, fontsize=32) savefig('stix_fonts_example') Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年09月01日 21:09:09 UTC (rev 6058) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年09月01日 22:27:07 UTC (rev 6059) @@ -204,7 +204,7 @@ os.unlink(os.path.join(path,fname)) else: os.mkdir(backend) - + failures = [] for fullpath in files: print ('\tdriving %-40s' % (fullpath)), @@ -257,10 +257,14 @@ print (end_time - start_time), ret #os.system('%s %s %s' % (python, tmpfile_name, switchstring)) os.remove(tmpfile_name) + if ret: + failures.append(fullpath) + return failures if __name__ == '__main__': times = {} + failures = {} default_backends = ['agg', 'ps', 'svg', 'pdf', 'template'] if len(sys.argv)==2 and sys.argv[1]=='--clean': localdirs = [d for d in glob.glob('*') if os.path.isdir(d)] @@ -299,13 +303,16 @@ switchstring = ' '.join(switches) print 'testing %s %s' % (backend, switchstring) t0 = time.time() - drive(backend, python, switches) + failures[backend] = drive(backend, python, switches) t1 = time.time() times[backend] = (t1-t0)/60.0 # print times for backend, elapsed in times.items(): print 'Backend %s took %1.2f minutes to complete' % ( backend, elapsed) + failed = failures[backend] + if failed: + print ' Failures: ', failed if 'Template' in times: print '\ttemplate ratio %1.3f, template residual %1.3f' % ( elapsed/times['Template'], elapsed-times['Template']) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6062 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6062&view=rev Author: mdboom Date: 2008年09月03日 19:58:01 +0000 (2008年9月03日) Log Message: ----------- Add donut demo (to demonstrate compound paths) Modified Paths: -------------- trunk/matplotlib/examples/tests/backend_driver.py Added Paths: ----------- trunk/matplotlib/examples/api/donut_demo.py Added: trunk/matplotlib/examples/api/donut_demo.py =================================================================== --- trunk/matplotlib/examples/api/donut_demo.py (rev 0) +++ trunk/matplotlib/examples/api/donut_demo.py 2008年09月03日 19:58:01 UTC (rev 6062) @@ -0,0 +1,54 @@ +import numpy as np +import matplotlib.path as mpath +import matplotlib.patches as mpatches +import matplotlib.pyplot as plt + +def wise(v): + if v == 1: + return "CCW" + else: + return "CW" + +def make_circle(r): + t = np.arange(0, np.pi * 2.0, 0.01) + t = t.reshape((len(t), 1)) + x = r * np.cos(t) + y = r * np.sin(t) + return np.hstack((x, y)) + +Path = mpath.Path + +fig = plt.figure() +ax = fig.add_subplot(111) + +inside_vertices = make_circle(0.5) +outside_vertices = make_circle(1.0) +codes = np.ones(len(inside_vertices), dtype=mpath.Path.code_type) * mpath.Path.LINETO +codes[0] = mpath.Path.MOVETO + +for i, (inside, outside) in enumerate(((1, 1), (1, -1), (-1, 1), (-1, -1))): + # Concatenate the inside and outside subpaths together, changing their + # order as needed + vertices = np.concatenate((outside_vertices[::outside], + inside_vertices[::inside])) + # Shift the path + vertices[:, 0] += i * 2.5 + # The codes will be all "LINETO" commands, except for "MOVETO"s at the + # beginning of each subpath + all_codes = np.concatenate((codes, codes)) + # Create the Path object + path = mpath.Path(vertices, all_codes) + # Add plot it + patch = mpatches.PathPatch(path, facecolor='#885500', edgecolor='black') + ax.add_patch(patch) + + ax.annotate("Outside %s,\nInside %s" % (wise(outside), wise(inside)), + (i * 2.5, -1.5), va="top", ha="center") + +ax.set_xlim(-2,10) +ax.set_ylim(-3,2) +ax.set_title('Mmm, donuts!') +ax.set_aspect(1.0) +plt.show() + + Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年09月03日 19:15:22 UTC (rev 6061) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年09月03日 19:58:01 UTC (rev 6062) @@ -126,6 +126,8 @@ api_files = [ 'colorbar_only.py', 'color_cycle.py', + 'donut_demo.py', + 'path_patch_demo.py' ] units_dir = os.path.join('..', 'units') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6076 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6076&view=rev Author: mdboom Date: 2008年09月09日 12:58:33 +0000 (2008年9月09日) Log Message: ----------- Add unit test for Path.intersects_bbox. Modified Paths: -------------- trunk/matplotlib/examples/tests/backend_driver.py Added Paths: ----------- trunk/matplotlib/examples/api/bbox_intersect.py Added: trunk/matplotlib/examples/api/bbox_intersect.py =================================================================== --- trunk/matplotlib/examples/api/bbox_intersect.py (rev 0) +++ trunk/matplotlib/examples/api/bbox_intersect.py 2008年09月09日 12:58:33 UTC (rev 6076) @@ -0,0 +1,21 @@ +from pylab import * +import numpy as np +from matplotlib.transforms import Bbox +from matplotlib.path import Path +from matplotlib.patches import Rectangle + +rect = Rectangle((-1, -1), 2, 2, facecolor="#aaaaaa") +gca().add_patch(rect) +bbox = Bbox.from_bounds(-1, -1, 2, 2) + +for i in range(12): + vertices = (np.random.random((4, 2)) - 0.5) * 6.0 + vertices = np.ma.masked_array(vertices, [[False, False], [True, True], [False, False], [False, False]]) + path = Path(vertices) + if path.intersects_bbox(bbox): + color = 'r' + else: + color = 'b' + plot(vertices[:,0], vertices[:,1], color=color) + +show() Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年09月09日 12:33:03 UTC (rev 6075) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年09月09日 12:58:33 UTC (rev 6076) @@ -124,6 +124,7 @@ api_dir = os.path.join('..', 'api') api_files = [ + 'bbox_intersect.py', 'colorbar_only.py', 'color_cycle.py', 'donut_demo.py', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6092 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6092&view=rev Author: jdh2358 Date: 2008年09月13日 17:07:39 +0000 (2008年9月13日) Log Message: ----------- moved font examples to api Added Paths: ----------- trunk/matplotlib/examples/api/font_family_rc.py trunk/matplotlib/examples/api/font_file.py Removed Paths: ------------- trunk/matplotlib/examples/pylab_examples/font_family_rc.py trunk/matplotlib/examples/pylab_examples/font_file.py Copied: trunk/matplotlib/examples/api/font_family_rc.py (from rev 6091, trunk/matplotlib/examples/pylab_examples/font_family_rc.py) =================================================================== --- trunk/matplotlib/examples/api/font_family_rc.py (rev 0) +++ trunk/matplotlib/examples/api/font_family_rc.py 2008年09月13日 17:07:39 UTC (rev 6092) @@ -0,0 +1,29 @@ +""" +You can explicitly set which font family is picked up for a given font +style (eg 'serif', 'sans-serif', or 'monospace'). + +In the example below, we only allow one font family (Tahoma) for the +san-serif font style. You the default family with the font.family rc +param, eg:: + + rcParams['font.family'] = 'sans-serif' + +and for the font.family you set a list of font styles to try to find +in order:: + + rcParams['font.sans-serif'] = ['Tahoma', 'Bitstream Vera Sans', 'Lucida Grande', 'Verdana'] + + +""" +from matplotlib import rcParams +rcParams['font.family'] = 'sans-serif' +rcParams['font.sans-serif'] = ['Tahoma'] +import matplotlib.pyplot as plt + +fig = plt.figure() +ax = fig.add_subplot(111) +ax.plot([1,2,3], label='test') + +ax.legend() +plt.show() + Copied: trunk/matplotlib/examples/api/font_file.py (from rev 6091, trunk/matplotlib/examples/pylab_examples/font_file.py) =================================================================== --- trunk/matplotlib/examples/api/font_file.py (rev 0) +++ trunk/matplotlib/examples/api/font_file.py 2008年09月13日 17:07:39 UTC (rev 6092) @@ -0,0 +1,18 @@ +""" +Although it is usually not a good idea to explicitly point to a single +ttf file for a font instance, you can do so using the +font_manager.FontProperties fname argument (for a more flexible +solution, see the font_fmaily_rc.py and fonts_demo.py examples). +""" +import matplotlib.font_manager as fm + +import matplotlib.pyplot as plt + +fig = plt.figure() +ax = fig.add_subplot(111) +ax.plot([1,2,3]) + +prop = fm.FontProperties(fname='/Library/Fonts/Tahoma.ttf') +ax.set_title('this is a special font', fontproperties=prop) +plt.show() + Deleted: trunk/matplotlib/examples/pylab_examples/font_family_rc.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/font_family_rc.py 2008年09月13日 17:06:53 UTC (rev 6091) +++ trunk/matplotlib/examples/pylab_examples/font_family_rc.py 2008年09月13日 17:07:39 UTC (rev 6092) @@ -1,29 +0,0 @@ -""" -You can explicitly set which font family is picked up for a given font -style (eg 'serif', 'sans-serif', or 'monospace'). - -In the example below, we only allow one font family (Tahoma) for the -san-serif font style. You the default family with the font.family rc -param, eg:: - - rcParams['font.family'] = 'sans-serif' - -and for the font.family you set a list of font styles to try to find -in order:: - - rcParams['font.sans-serif'] = ['Tahoma', 'Bitstream Vera Sans', 'Lucida Grande', 'Verdana'] - - -""" -from matplotlib import rcParams -rcParams['font.family'] = 'sans-serif' -rcParams['font.sans-serif'] = ['Tahoma'] -import matplotlib.pyplot as plt - -fig = plt.figure() -ax = fig.add_subplot(111) -ax.plot([1,2,3], label='test') - -ax.legend() -plt.show() - Deleted: trunk/matplotlib/examples/pylab_examples/font_file.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/font_file.py 2008年09月13日 17:06:53 UTC (rev 6091) +++ trunk/matplotlib/examples/pylab_examples/font_file.py 2008年09月13日 17:07:39 UTC (rev 6092) @@ -1,18 +0,0 @@ -""" -Although it is usually not a good idea to explicitly point to a single -ttf file for a font instance, you can do so using the -font_manager.FontProperties fname argument (for a more flexible -solution, see the font_fmaily_rc.py and fonts_demo.py examples). -""" -import matplotlib.font_manager as fm - -import matplotlib.pyplot as plt - -fig = plt.figure() -ax = fig.add_subplot(111) -ax.plot([1,2,3]) - -prop = fm.FontProperties(fname='/Library/Fonts/Tahoma.ttf') -ax.set_title('this is a special font', fontproperties=prop) -plt.show() - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6102 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6102&view=rev Author: jdh2358 Date: 2008年09月17日 20:53:16 +0000 (2008年9月17日) Log Message: ----------- committed Jae-Joons fancy box examples Modified Paths: -------------- trunk/matplotlib/examples/tests/backend_driver.py Added Paths: ----------- trunk/matplotlib/examples/pylab_examples/fancybox_demo.py trunk/matplotlib/examples/pylab_examples/fancytextbox_demo.py Added: trunk/matplotlib/examples/pylab_examples/fancybox_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/fancybox_demo.py (rev 0) +++ trunk/matplotlib/examples/pylab_examples/fancybox_demo.py 2008年09月17日 20:53:16 UTC (rev 6102) @@ -0,0 +1,171 @@ +import matplotlib.pyplot as plt +import matplotlib.transforms as mtransforms +from matplotlib.patches import FancyBboxPatch + + +# Bbox object around which the fancy box will be drawn. +bb = mtransforms.Bbox([[0.3, 0.4], [0.7, 0.6]]) + +def draw_bbox(ax, bb): + # boxstyle=square with pad=0, i.e. bbox itself. + p_bbox = FancyBboxPatch((bb.xmin, bb.ymin), + abs(bb.width), abs(bb.height), + boxstyle="square,pad=0.", + ec="k", fc="none", zorder=10., + ) + ax.add_patch(p_bbox) + +def test1(ax): + + # a fancy box with round corners. pad=0.1 + p_fancy = FancyBboxPatch((bb.xmin, bb.ymin), + abs(bb.width), abs(bb.height), + boxstyle="round,pad=0.1", + fc=(1., .8, 1.), + ec=(1., 0.5, 1.)) + + + ax.add_patch(p_fancy) + + ax.text(0.1, 0.8, + r' boxstyle="round,pad=0.1"', + size=10, transform=ax.transAxes) + + # draws control points for the fancy box. + #l = p_fancy.get_path().vertices + #ax.plot(l[:,0], l[:,1], ".") + + # draw the original bbox in black + draw_bbox(ax, bb) + + +def test2(ax): + + # bbox=round has two optional argument. pad and rounding_size. + # They can be set during the initiallization. + p_fancy = FancyBboxPatch((bb.xmin, bb.ymin), + abs(bb.width), abs(bb.height), + boxstyle="round,pad=0.1", + fc=(1., .8, 1.), + ec=(1., 0.5, 1.)) + + + ax.add_patch(p_fancy) + + # boxstyle and its argument can be later modified with + # set_boxstyle method. Note that the old attributes are simply + # forgotten even if the boxstyle name is same. + + p_fancy.set_boxstyle("round,pad=0.1, rounding_size=0.2") + #or + #p_fancy.set_boxstyle("round", pad=0.1, rounding_size=0.2) + + ax.text(0.1, 0.8, + ' boxstyle="round,pad=0.1\n rounding\\_size=0.2"', + size=10, transform=ax.transAxes) + + # draws control points for the fancy box. + #l = p_fancy.get_path().vertices + #ax.plot(l[:,0], l[:,1], ".") + + draw_bbox(ax, bb) + + + +def test3(ax): + + # mutation_scale determine overall scale of the mutation, + # i.e. both pad and rounding_size is scaled according to this + # value. + p_fancy = FancyBboxPatch((bb.xmin, bb.ymin), + abs(bb.width), abs(bb.height), + boxstyle="round,pad=0.1", + mutation_scale=2., + fc=(1., .8, 1.), + ec=(1., 0.5, 1.)) + + + ax.add_patch(p_fancy) + + ax.text(0.1, 0.8, + ' boxstyle="round,pad=0.1"\n mutation\\_scale=2', + size=10, transform=ax.transAxes) + + # draws control points for the fancy box. + #l = p_fancy.get_path().vertices + #ax.plot(l[:,0], l[:,1], ".") + + draw_bbox(ax, bb) + + + +def test4(ax): + + # When the aspect ratio of the axes is not 1, the fancy box may + # not be what you expected (green) + + p_fancy = FancyBboxPatch((bb.xmin, bb.ymin), + abs(bb.width), abs(bb.height), + boxstyle="round,pad=0.2", + fc="none", + ec=(0., .5, 0.), zorder=4) + + + ax.add_patch(p_fancy) + + + # You can compensate this by setting the mutation_aspect (pink). + p_fancy = FancyBboxPatch((bb.xmin, bb.ymin), + abs(bb.width), abs(bb.height), + boxstyle="round,pad=0.3", + mutation_aspect=.5, + fc=(1., 0.8, 1.), + ec=(1., 0.5, 1.)) + + + ax.add_patch(p_fancy) + + ax.text(0.1, 0.8, + ' boxstyle="round,pad=0.3"\n mutation\\_aspect=.5', + size=10, transform=ax.transAxes) + + draw_bbox(ax, bb) + + + +def test_all(): + plt.clf() + + ax = plt.subplot(2, 2, 1) + test1(ax) + ax.set_xlim(0., 1.) + ax.set_ylim(0., 1.) + ax.set_title("test1") + ax.set_aspect(1.) + + + ax = plt.subplot(2, 2, 2) + ax.set_title("test2") + test2(ax) + ax.set_xlim(0., 1.) + ax.set_ylim(0., 1.) + ax.set_aspect(1.) + + ax = plt.subplot(2, 2, 3) + ax.set_title("test3") + test3(ax) + ax.set_xlim(0., 1.) + ax.set_ylim(0., 1.) + ax.set_aspect(1) + + ax = plt.subplot(2, 2, 4) + ax.set_title("test4") + test4(ax) + ax.set_xlim(-0.5, 1.5) + ax.set_ylim(0., 1.) + ax.set_aspect(2.) + + plt.draw() + plt.show() + +test_all() Added: trunk/matplotlib/examples/pylab_examples/fancytextbox_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/fancytextbox_demo.py (rev 0) +++ trunk/matplotlib/examples/pylab_examples/fancytextbox_demo.py 2008年09月17日 20:53:16 UTC (rev 6102) @@ -0,0 +1,21 @@ +import matplotlib.pyplot as plt + +plt.text(0.6, 0.5, "test", size=50, rotation=30., + ha="center", va="center", + bbox = dict(boxstyle="round", + ec=(1., 0.5, 0.5), + fc=(1., 0.8, 0.8), + ) + ) + +plt.text(0.5, 0.4, "test", size=50, rotation=-30., + ha="right", va="top", + bbox = dict(boxstyle="square", + ec=(1., 0.5, 0.5), + fc=(1., 0.8, 0.8), + ) + ) + + +plt.draw() +plt.show() Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年09月17日 20:52:08 UTC (rev 6101) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年09月17日 20:53:16 UTC (rev 6102) @@ -52,6 +52,8 @@ 'date_demo2.py', 'equal_aspect_ratio.py', 'errorbar_limits.py', + 'fancybox_demo.py', + 'fancytextbox_demo.py', 'figimage_demo.py', 'figlegend_demo.py', 'figure_title.py', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6243 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6243&view=rev Author: jdh2358 Date: 2008年10月17日 16:03:23 +0000 (2008年10月17日) Log Message: ----------- moved two scales example to api Added Paths: ----------- trunk/matplotlib/examples/api/two_scales.py Removed Paths: ------------- trunk/matplotlib/examples/pylab_examples/two_scales.py Copied: trunk/matplotlib/examples/api/two_scales.py (from rev 6242, trunk/matplotlib/examples/pylab_examples/two_scales.py) =================================================================== --- trunk/matplotlib/examples/api/two_scales.py (rev 0) +++ trunk/matplotlib/examples/api/two_scales.py 2008年10月17日 16:03:23 UTC (rev 6243) @@ -0,0 +1,40 @@ +#!/usr/bin/env python +""" + +Demonstrate how to do two plots on the same axes with different left +right scales. + + +The trick is to use *2 different axes*. Turn the axes rectangular +frame off on the 2nd axes to keep it from obscuring the first. +Manually set the tick locs and labels as desired. You can use +separate matplotlib.ticker formatters and locators as desired since +the two axes are independent. + +This is acheived in the following example by calling pylab's twinx() +function, which performs this work. See the source of twinx() in +pylab.py for an example of how to do it for different x scales. (Hint: +use the xaxis instance and call tick_bottom and tick_top in place of +tick_left and tick_right.) + +""" + +import numpy as np +import matplotlib.pyplot as plt + +fig = plt.figure() +ax1 = fig.add_subplot(111) +t = np.arange(0.01, 10.0, 0.01) +s1 = np.exp(t) +ax1.plot(t, s1, 'b-') +ax1.set_xlabel('time (s)') +ax1.set_ylabel('exp') + + +# turn off the 2nd axes rectangle with frameon kwarg +ax2 = ax1.twinx() +s2 = np.sin(2*np.pi*t) +ax2.plot(t, s2, 'r.') +ax2.set_ylabel('sin') +plt.show() + Deleted: trunk/matplotlib/examples/pylab_examples/two_scales.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/two_scales.py 2008年10月17日 16:02:52 UTC (rev 6242) +++ trunk/matplotlib/examples/pylab_examples/two_scales.py 2008年10月17日 16:03:23 UTC (rev 6243) @@ -1,40 +0,0 @@ -#!/usr/bin/env python -""" - -Demonstrate how to do two plots on the same axes with different left -right scales. - - -The trick is to use *2 different axes*. Turn the axes rectangular -frame off on the 2nd axes to keep it from obscuring the first. -Manually set the tick locs and labels as desired. You can use -separate matplotlib.ticker formatters and locators as desired since -the two axes are independent. - -This is acheived in the following example by calling pylab's twinx() -function, which performs this work. See the source of twinx() in -pylab.py for an example of how to do it for different x scales. (Hint: -use the xaxis instance and call tick_bottom and tick_top in place of -tick_left and tick_right.) - -""" - -import numpy as np -import matplotlib.pyplot as plt - -fig = plt.figure() -ax1 = fig.add_subplot(111) -t = np.arange(0.01, 10.0, 0.01) -s1 = np.exp(t) -ax1.plot(t, s1, 'b-') -ax1.set_xlabel('time (s)') -ax1.set_ylabel('exp') - - -# turn off the 2nd axes rectangle with frameon kwarg -ax2 = ax1.twinx() -s2 = np.sin(2*np.pi*t) -ax2.plot(t, s2, 'r.') -ax2.set_ylabel('sin') -plt.show() - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6298 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6298&view=rev Author: efiring Date: 2008年10月22日 19:28:14 +0000 (2008年10月22日) Log Message: ----------- update backend_driver for new location of two_scales.py Modified Paths: -------------- trunk/matplotlib/examples/api/two_scales.py trunk/matplotlib/examples/tests/backend_driver.py Modified: trunk/matplotlib/examples/api/two_scales.py =================================================================== --- trunk/matplotlib/examples/api/two_scales.py 2008年10月22日 18:45:10 UTC (rev 6297) +++ trunk/matplotlib/examples/api/two_scales.py 2008年10月22日 19:28:14 UTC (rev 6298) @@ -11,12 +11,14 @@ separate matplotlib.ticker formatters and locators as desired since the two axes are independent. -This is acheived in the following example by calling pylab's twinx() -function, which performs this work. See the source of twinx() in -pylab.py for an example of how to do it for different x scales. (Hint: +This is achieved in the following example by calling the Axes.twinx() +method, which performs this work. See the source of twinx() in +axes.py for an example of how to do it for different x scales. (Hint: use the xaxis instance and call tick_bottom and tick_top in place of tick_left and tick_right.) +The twinx and twiny methods are also exposed as pyplot functions. + """ import numpy as np Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年10月22日 18:45:10 UTC (rev 6297) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年10月22日 19:28:14 UTC (rev 6298) @@ -117,7 +117,7 @@ 'text_rotation.py', 'text_themes.py', # 'tex_demo.py', - 'two_scales.py', +# 'two_scales.py', 'unicode_demo.py', 'vline_demo.py', 'xcorr_demo.py', @@ -132,7 +132,8 @@ 'color_cycle.py', 'donut_demo.py', 'path_patch_demo.py', - 'quad_bezier.py' + 'quad_bezier.py', + 'two_scales.py' ] units_dir = os.path.join('..', 'units') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6527 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6527&view=rev Author: jdh2358 Date: 2008年12月09日 03:24:44 +0000 (2008年12月09日) Log Message: ----------- added more examples to backend driver Modified Paths: -------------- trunk/matplotlib/examples/api/watermark_image.py trunk/matplotlib/examples/api/watermark_text.py trunk/matplotlib/examples/pylab_examples/annotation_demo.py trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py trunk/matplotlib/examples/pylab_examples/manual_axis.py trunk/matplotlib/examples/tests/backend_driver.py Modified: trunk/matplotlib/examples/api/watermark_image.py =================================================================== --- trunk/matplotlib/examples/api/watermark_image.py 2008年12月08日 23:28:55 UTC (rev 6526) +++ trunk/matplotlib/examples/api/watermark_image.py 2008年12月09日 03:24:44 UTC (rev 6527) @@ -18,5 +18,6 @@ ax.grid() fig.figimage(im, 10, 10) -fig.savefig('watermarked', transparent=True) +#fig.savefig('watermarked', transparent=True) +plt.show() Modified: trunk/matplotlib/examples/api/watermark_text.py =================================================================== --- trunk/matplotlib/examples/api/watermark_text.py 2008年12月08日 23:28:55 UTC (rev 6526) +++ trunk/matplotlib/examples/api/watermark_text.py 2008年12月09日 03:24:44 UTC (rev 6527) @@ -2,8 +2,8 @@ Use a Text as a watermark """ import numpy as np -import matplotlib -matplotlib.use('Agg') +#import matplotlib +#matplotlib.use('Agg') import matplotlib.pyplot as plt @@ -18,5 +18,7 @@ fontsize=50, color='gray', ha='right', va='bottom', alpha=0.5) -fig.savefig('watermarked_text', transparent=True) +#fig.savefig('watermarked_text', transparent=True) + +plt.show() Modified: trunk/matplotlib/examples/pylab_examples/annotation_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/annotation_demo.py 2008年12月08日 23:28:55 UTC (rev 6526) +++ trunk/matplotlib/examples/pylab_examples/annotation_demo.py 2008年12月09日 03:24:44 UTC (rev 6527) @@ -82,7 +82,7 @@ horizontalalignment='right', verticalalignment='bottom', fontsize=20) - fig.savefig('annotation_coords') + #fig.savefig('annotation_coords') if 1: # you can specify the xypoint and the xytext in different @@ -111,7 +111,7 @@ horizontalalignment='left', verticalalignment='bottom', ) - fig.savefig('annotation_polar') + #fig.savefig('annotation_polar') if 1: # You can also use polar notation on a catesian axes. Here the @@ -138,7 +138,7 @@ ax.set_xlim(-20, 20) ax.set_ylim(-20, 20) - fig.savefig('annotation_ellipse') + #fig.savefig('annotation_ellipse') Modified: trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py 2008年12月08日 23:28:55 UTC (rev 6526) +++ trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py 2008年12月09日 03:24:44 UTC (rev 6527) @@ -89,5 +89,4 @@ n, bins, patches = P.hist( [x0,x1,x2], 10, histtype='bar') - -P.show() \ No newline at end of file +P.show() Modified: trunk/matplotlib/examples/pylab_examples/manual_axis.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/manual_axis.py 2008年12月08日 23:28:55 UTC (rev 6526) +++ trunk/matplotlib/examples/pylab_examples/manual_axis.py 2008年12月09日 03:24:44 UTC (rev 6527) @@ -52,6 +52,6 @@ ax.set_ylim(-1.5, 1.5) make_xaxis(ax, 0, offset=0.1, **props) make_yaxis(ax, 0, offset=5, **props) -fig.savefig('manual_axis.png', dpi=100, facecolor='white', edgecolor='white') +#fig.savefig('manual_axis.png', dpi=100, facecolor='white', edgecolor='white') show() Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年12月08日 23:28:55 UTC (rev 6526) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年12月09日 03:24:44 UTC (rev 6527) @@ -25,85 +25,154 @@ pylab_dir = os.path.join('..', 'pylab_examples') pylab_files = [ + 'two_scales.py', + + 'accented_text.py', 'alignment_test.py', + 'annotation_demo.py', + 'annotation_demo.py', + 'annotation_demo2.py', + 'annotation_demo2.py', + 'anscombe.py', 'arctest.py', 'arrow_demo.py', - #'auto_layout.py', 'axes_demo.py', + 'axes_props.py', 'axhspan_demo.py', + 'axis_equal_demo.py', 'bar_stacked.py', + 'barb_demo.py', 'barchart_demo.py', - 'barb_demo.py', 'barcode_demo.py', + 'barh_demo.py', 'boxplot_demo.py', 'broken_barh.py', - 'barh_demo.py', + 'clippedline.py', + 'cohere_demo.py', + 'color_by_yvalue.py', 'color_demo.py', - 'cohere_demo.py', + 'colorbar_tick_labelling_demo.py', 'contour_demo.py', + 'contour_image.py', 'contour_label_demo.py', 'contourf_demo.py', + 'contourf_log.py', + 'coords_demo.py', + 'coords_report.py', + 'csd_demo.py', + 'cursor_demo.py', 'custom_cmap.py', - 'geo_demo.py', - 'griddata_demo.py', - 'csd_demo.py', + 'custom_figure_class.py', 'custom_ticker1.py', 'customize_rc.py', + 'dash_control.py', + 'dashpointlabel.py', 'date_demo1.py', 'date_demo2.py', + 'date_demo_convert.py', + 'date_demo_rrule.py', + 'date_index_formatter.py', + 'dolphin.py', 'ellipse_collection.py', + 'ellipse_demo.py', + 'ellipse_rotated.py', 'equal_aspect_ratio.py', + 'errorbar_demo.py', 'errorbar_limits.py', + 'fancyarrow_demo.py', 'fancybox_demo.py', + 'fancybox_demo2.py', 'fancytextbox_demo.py', 'figimage_demo.py', 'figlegend_demo.py', 'figure_title.py', + 'fill_between.py', 'fill_demo.py', + 'fill_demo2.py', + 'fill_spiral.py', 'finance_demo.py', + 'findobj_demo.py', + 'fonts_demo.py', 'fonts_demo_kw.py', + 'ganged_plots.py', + 'geo_demo.py', + 'gradient_bar.py', + 'griddata_demo.py', + 'hatch_demo.py', 'hexbin_demo.py', 'hexbin_demo2.py', + 'hist_colormapped.py', 'histogram_demo.py', + 'histogram_demo_extended.py', 'hline_demo.py', + + 'image_clip_path.py', 'image_demo.py', 'image_demo2.py', + 'image_demo3.py', + 'image_interp.py', 'image_masked.py', + 'image_nonuniform.py', 'image_origin.py', - 'image_nonuniform.py', + 'image_slices_viewer.py', + 'integral_demo.py', + 'interp_demo.py', 'invert_axes.py', 'layer_images.py', 'legend_auto.py', 'legend_demo.py', 'legend_demo2.py', + 'legend_demo3.py', + 'legend_demo3.py', + 'legend_scatter.py', 'line_collection.py', 'line_collection2.py', 'line_styles.py', + 'log_bar.py', 'log_demo.py', 'log_test.py', 'major_minor_demo1.py', 'major_minor_demo2.py', + 'manual_axis.py', 'masked_demo.py', 'mathtext_demo.py', + 'mathtext_examples.py', + 'matplotlib_icon.py', + 'matshow.py', + 'mri_demo.py', 'mri_with_eeg.py', + 'multi_image.py', + 'multiline.py', 'multiple_figs_demo.py', - 'multi_image.py', 'nan_test.py', + 'newscalarformatter_demo.py', 'pcolor_demo.py', 'pcolor_demo2.py', + 'pcolor_log.py', 'pcolor_small.py', 'pie_demo.py', + 'plotfile_demo.py', + 'polar_bar.py', 'polar_demo.py', + 'polar_legend.py', 'polar_scatter.py', + 'poormans_contour.py', 'psd_demo.py', + 'psd_demo2.py', + 'psd_demo3.py', 'quadmesh_demo.py', 'quiver_demo.py', + 'scatter_custom_symbol.py', 'scatter_demo.py', 'scatter_demo2.py', + 'scatter_masked.py', + 'scatter_profile.py', 'scatter_star_poly.py', + 'set_and_get.py', + 'shared_axis_across_figures.py', 'shared_axis_demo.py', - 'shared_axis_across_figures.py', 'simple_plot.py', + 'simplification_clipping_test.py', 'specgram_demo.py', 'spy_demos.py', 'stem_plot.py', @@ -111,23 +180,48 @@ 'stix_fonts_demo.py', 'stock_demo.py', 'subplot_demo.py', + 'subplots_adjust.py', 'symlog_demo.py', - # 'set_and_get.py', 'table_demo.py', 'text_handles.py', 'text_rotation.py', + 'text_rotation_relative_to_line.py', 'text_themes.py', -# 'tex_demo.py', -# 'two_scales.py', + 'transoffset.py', 'unicode_demo.py', + 'vertical_ticklabels.py', 'vline_demo.py', + 'webapp_demo.py', 'xcorr_demo.py', 'zorder_demo.py', + ] api_dir = os.path.join('..', 'api') api_files = [ + 'agg_oo.py', + 'barchart_demo.py', + 'collections_demo.py', + 'custom_projection_example.py', + 'custom_scale_example.py', + 'date_demo.py', + 'date_index_formatter.py', + 'font_family_rc.py', + 'font_file.py', + 'histogram_demo.py', + 'image_zcoord.py', + 'legend_demo.py', + 'line_with_text.py', + 'logo2.py', + 'mathtext_asarray.py', + 'patch_collection.py', + 'scatter_piecharts.py', + 'span_regions.py', + 'unicode_minus.py', + 'watermark_image.py', + 'watermark_text.py', + 'bbox_intersect.py', 'colorbar_only.py', 'color_cycle.py', @@ -178,17 +272,23 @@ report_missing(api_dir, api_files) report_missing(units_dir, units_files) -files = [os.path.join(pylab_dir, fname) for fname in pylab_files] +\ - [os.path.join(api_dir, fname) for fname in api_files] +\ +files = ( + [os.path.join(api_dir, fname) for fname in api_files] + + [os.path.join(pylab_dir, fname) for fname in pylab_files] + [os.path.join(units_dir, fname) for fname in units_files] + ) # tests known to fail on a given backend failbackend = dict( - SVG = ('tex_demo.py,'), + svg = ('tex_demo.py', ), + agg = ('hyperlinks.py', ), + pdf = ('hyperlinks.py', ), + ps = ('hyperlinks.py', ), ) + try: import subprocess def run(arglist): @@ -256,7 +356,7 @@ if backend in rcsetup.interactive_bk: tmpfile.write('show()') else: - tmpfile.write('savefig("%s", dpi=150)' % outfile) + tmpfile.write('\nsavefig("%s", dpi=150)' % outfile) tmpfile.close() start_time = time.time() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7380 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7380&view=rev Author: jdh2358 Date: 2009年08月05日 15:59:24 +0000 (2009年8月05日) Log Message: ----------- port more examples over to sample data Modified Paths: -------------- trunk/matplotlib/examples/api/date_index_formatter.py trunk/matplotlib/examples/misc/rec_groupby_demo.py trunk/matplotlib/examples/misc/rec_join_demo.py Modified: trunk/matplotlib/examples/api/date_index_formatter.py =================================================================== --- trunk/matplotlib/examples/api/date_index_formatter.py 2009年08月05日 15:57:31 UTC (rev 7379) +++ trunk/matplotlib/examples/api/date_index_formatter.py 2009年08月05日 15:59:24 UTC (rev 7380) @@ -9,7 +9,7 @@ import matplotlib.cbook as cbook import matplotlib.ticker as ticker -datafile = cbook.get_sample_data('aapl.csv', asobj=False) +datafile = cbook.get_sample_data('aapl.csv', asfileobj=False) print 'loading', datafile r = mlab.csv2rec(datafile) Modified: trunk/matplotlib/examples/misc/rec_groupby_demo.py =================================================================== --- trunk/matplotlib/examples/misc/rec_groupby_demo.py 2009年08月05日 15:57:31 UTC (rev 7379) +++ trunk/matplotlib/examples/misc/rec_groupby_demo.py 2009年08月05日 15:59:24 UTC (rev 7380) @@ -2,11 +2,9 @@ import matplotlib.mlab as mlab import matplotlib.cbook as cbook -datafile = cbook.get_sample_data('aapl.csv', asobj=False) +datafile = cbook.get_sample_data('aapl.csv', asfileobj=False) print 'loading', datafile r = mlab.csv2rec(datafile) - -r = mlab.csv2rec('../data/aapl.csv') r.sort() def daily_return(prices): Modified: trunk/matplotlib/examples/misc/rec_join_demo.py =================================================================== --- trunk/matplotlib/examples/misc/rec_join_demo.py 2009年08月05日 15:57:31 UTC (rev 7379) +++ trunk/matplotlib/examples/misc/rec_join_demo.py 2009年08月05日 15:59:24 UTC (rev 7380) @@ -2,7 +2,7 @@ import matplotlib.mlab as mlab import matplotlib.cbook as cbook -datafile = cbook.get_sample_data('aapl.csv', asobj=False) +datafile = cbook.get_sample_data('aapl.csv', asfileobj=False) print 'loading', datafile r = mlab.csv2rec(datafile) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7384 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7384&view=rev Author: jdh2358 Date: 2009年08月05日 16:24:03 +0000 (2009年8月05日) Log Message: ----------- fixed typo in sample data examples Modified Paths: -------------- trunk/matplotlib/examples/api/watermark_image.py trunk/matplotlib/examples/user_interfaces/embedding_in_wx3.py trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_custom.py trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_simple.py Modified: trunk/matplotlib/examples/api/watermark_image.py =================================================================== --- trunk/matplotlib/examples/api/watermark_image.py 2009年08月05日 16:23:06 UTC (rev 7383) +++ trunk/matplotlib/examples/api/watermark_image.py 2009年08月05日 16:24:03 UTC (rev 7384) @@ -8,7 +8,7 @@ import matplotlib.image as image import matplotlib.pyplot as plt -datafile = cbook.get_sample_data('logo2.png', asobj=False) +datafile = cbook.get_sample_data('logo2.png', asfileobj=False) print 'loading', datafile im = image.imread(datafile) im[:,:,-1] = 0.5 # set the alpha channel Modified: trunk/matplotlib/examples/user_interfaces/embedding_in_wx3.py =================================================================== --- trunk/matplotlib/examples/user_interfaces/embedding_in_wx3.py 2009年08月05日 16:23:06 UTC (rev 7383) +++ trunk/matplotlib/examples/user_interfaces/embedding_in_wx3.py 2009年08月05日 16:24:03 UTC (rev 7384) @@ -102,7 +102,7 @@ class MyApp(wx.App): def OnInit(self): - xrcfile = cbook.get_sample_data('embedding_in_wx3.xrc', asobj=False) + xrcfile = cbook.get_sample_data('embedding_in_wx3.xrc', asfileobj=False) print 'loading', xrcfile self.res = xrc.XmlResource(xrcfile) Modified: trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_custom.py =================================================================== --- trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_custom.py 2009年08月05日 16:23:06 UTC (rev 7383) +++ trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_custom.py 2009年08月05日 16:24:03 UTC (rev 7384) @@ -10,7 +10,7 @@ import mpl_toolkits.gtktools as gtktools -datafile = cbook.get_sample_data('demodata.csv', asobj=False) +datafile = cbook.get_sample_data('demodata.csv', asfileobj=False) r = mlab.csv2rec(datafile, converterd={'weekdays':str}) Modified: trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_simple.py =================================================================== --- trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_simple.py 2009年08月05日 16:23:06 UTC (rev 7383) +++ trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_simple.py 2009年08月05日 16:24:03 UTC (rev 7384) @@ -8,7 +8,7 @@ import matplotlib.cbook as cbook import mpl_toolkits.gtktools as gtktools -datafile = cbook.get_sample_data('demodata.csv', asobj=False) +datafile = cbook.get_sample_data('demodata.csv', asfileobj=False) r = mlab.csv2rec(datafile, converterd={'weekdays':str}) liststore, treeview, win = gtktools.edit_recarray(r) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8469 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8469&view=rev Author: efiring Date: 2010年06月26日 08:14:01 +0000 (2010年6月26日) Log Message: ----------- examples: fix references to MATLAB Modified Paths: -------------- trunk/matplotlib/examples/animation/movie_demo.py trunk/matplotlib/examples/pylab_examples/axes_props.py trunk/matplotlib/examples/pylab_examples/color_demo.py trunk/matplotlib/examples/pylab_examples/polar_demo.py trunk/matplotlib/examples/pylab_examples/psd_demo.py trunk/matplotlib/examples/pylab_examples/psd_demo3.py trunk/matplotlib/examples/pylab_examples/psd_demo_complex.py trunk/matplotlib/examples/pylab_examples/set_and_get.py trunk/matplotlib/examples/pylab_examples/text_handles.py Modified: trunk/matplotlib/examples/animation/movie_demo.py =================================================================== --- trunk/matplotlib/examples/animation/movie_demo.py 2010年06月26日 07:45:26 UTC (rev 8468) +++ trunk/matplotlib/examples/animation/movie_demo.py 2010年06月26日 08:14:01 UTC (rev 8469) @@ -87,7 +87,7 @@ for i in range(len(y)) : # - # The next four lines are just like Matlab. + # The next four lines are just like MATLAB. # plt.plot(x,y[i],'b.') plt.axis((x[0],x[-1],-0.25,1)) Modified: trunk/matplotlib/examples/pylab_examples/axes_props.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/axes_props.py 2010年06月26日 07:45:26 UTC (rev 8468) +++ trunk/matplotlib/examples/pylab_examples/axes_props.py 2010年06月26日 08:14:01 UTC (rev 8469) @@ -10,7 +10,7 @@ plot(t, s) grid(True) -# matlab style +# MATLAB style xticklines = getp(gca(), 'xticklines') yticklines = getp(gca(), 'yticklines') xgridlines = getp(gca(), 'xgridlines') Modified: trunk/matplotlib/examples/pylab_examples/color_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/color_demo.py 2010年06月26日 07:45:26 UTC (rev 8468) +++ trunk/matplotlib/examples/pylab_examples/color_demo.py 2010年06月26日 08:14:01 UTC (rev 8469) @@ -2,7 +2,7 @@ """ matplotlib gives you 4 ways to specify colors, - 1) as a single letter string, ala matlab + 1) as a single letter string, ala MATLAB 2) as an html style hex string or html color name Modified: trunk/matplotlib/examples/pylab_examples/polar_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/polar_demo.py 2010年06月26日 07:45:26 UTC (rev 8468) +++ trunk/matplotlib/examples/pylab_examples/polar_demo.py 2010年06月26日 08:14:01 UTC (rev 8469) @@ -28,7 +28,7 @@ # # you could change the radial bounding box (zoom out) by setting the # ylim (radial coordinate is the second argument to the plot command, -# as in matlab(TM), though this is not advised currently because it is not +# as in MATLAB, though this is not advised currently because it is not # clear to me how the axes should behave in the change of view limits. # Please advise me if you have opinions. Likewise, the pan/zoom # controls probably do not do what you think they do and are better @@ -48,7 +48,7 @@ rc('ytick', labelsize=15) # force square figure and square axes looks better for polar, IMO -width, height = matplotlib.rcParams['figure.figsize'] +width, height = matplotlib.rcParams['figure.figsize'] size = min(width, height) # make a square figure fig = figure(figsize=(size, size)) Modified: trunk/matplotlib/examples/pylab_examples/psd_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/psd_demo.py 2010年06月26日 07:45:26 UTC (rev 8468) +++ trunk/matplotlib/examples/pylab_examples/psd_demo.py 2010年06月26日 08:14:01 UTC (rev 8469) @@ -19,7 +19,7 @@ show() """ -% compare with matlab(TM) +% compare with MATLAB dt = 0.01; t = [0:dt:10]; nse = randn(size(t)); Modified: trunk/matplotlib/examples/pylab_examples/psd_demo3.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/psd_demo3.py 2010年06月26日 07:45:26 UTC (rev 8468) +++ trunk/matplotlib/examples/pylab_examples/psd_demo3.py 2010年06月26日 08:14:01 UTC (rev 8469) @@ -1,6 +1,6 @@ -#This is a ported version of a Matlab example from the signal processing +#This is a ported version of a MATLAB example from the signal processing #toolbox that showed some difference at one time between Matplotlib's and -#MatLab's scaling of the PSD. +#MATLAB's scaling of the PSD. import numpy as np import matplotlib.pyplot as plt Modified: trunk/matplotlib/examples/pylab_examples/psd_demo_complex.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/psd_demo_complex.py 2010年06月26日 07:45:26 UTC (rev 8468) +++ trunk/matplotlib/examples/pylab_examples/psd_demo_complex.py 2010年06月26日 08:14:01 UTC (rev 8469) @@ -1,6 +1,6 @@ -#This is a ported version of a Matlab example from the signal processing +#This is a ported version of a MATLAB example from the signal processing #toolbox that showed some difference at one time between Matplotlib's and -#MatLab's scaling of the PSD. This differs from psd_demo3.py in that +#MATLAB's scaling of the PSD. This differs from psd_demo3.py in that #this uses a complex signal, so we can see that complex PSD's work properly import numpy as np import matplotlib.pyplot as plt Modified: trunk/matplotlib/examples/pylab_examples/set_and_get.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/set_and_get.py 2010年06月26日 07:45:26 UTC (rev 8468) +++ trunk/matplotlib/examples/pylab_examples/set_and_get.py 2010年06月26日 08:14:01 UTC (rev 8469) @@ -1,6 +1,6 @@ """ -matlab(TM) and pylab allow you to use setp and get to set and get +MATLAB and pylab allow you to use setp and get to set and get object properties, as well as to do introspection on the object set Modified: trunk/matplotlib/examples/pylab_examples/text_handles.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/text_handles.py 2010年06月26日 07:45:26 UTC (rev 8468) +++ trunk/matplotlib/examples/pylab_examples/text_handles.py 2010年06月26日 08:14:01 UTC (rev 8469) @@ -2,7 +2,7 @@ #Controlling the properties of axis text using handles # See examples/text_themes.py for a more elegant, pythonic way to control -# fonts. After all, if we were slaves to matlab(TM) , we wouldn't be +# fonts. After all, if we were slaves to MATLAB , we wouldn't be # using python! from pylab import * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8659 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8659&view=rev Author: ryanmay Date: 2010年08月26日 03:19:14 +0000 (2010年8月26日) Log Message: ----------- Move previous animation examples to make room for new ones. Added Paths: ----------- trunk/matplotlib/examples/old_animation/ Removed Paths: ------------- trunk/matplotlib/examples/animation/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8660 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8660&view=rev Author: ryanmay Date: 2010年08月26日 03:23:25 +0000 (2010年8月26日) Log Message: ----------- Add previous animation examples ported to new framework, as well as a few new ones. Added Paths: ----------- trunk/matplotlib/examples/animation/ trunk/matplotlib/examples/animation/animate_decay.py trunk/matplotlib/examples/animation/dynamic_image.py trunk/matplotlib/examples/animation/dynamic_image2.py trunk/matplotlib/examples/animation/histogram.py trunk/matplotlib/examples/animation/random_data.py trunk/matplotlib/examples/animation/simple_3danim.py trunk/matplotlib/examples/animation/simple_anim.py trunk/matplotlib/examples/animation/strip_chart_demo.py trunk/matplotlib/examples/animation/subplots.py Added: trunk/matplotlib/examples/animation/animate_decay.py =================================================================== --- trunk/matplotlib/examples/animation/animate_decay.py (rev 0) +++ trunk/matplotlib/examples/animation/animate_decay.py 2010年08月26日 03:23:25 UTC (rev 8660) @@ -0,0 +1,36 @@ +import numpy as np +import matplotlib.pyplot as plt +from animation import FuncAnimation + +def data_gen(): + t = data_gen.t + cnt = 0 + while cnt < 1000: + cnt+=1 + t += 0.05 + yield t, np.sin(2*np.pi*t) * np.exp(-t/10.) +data_gen.t = 0 + +fig = plt.figure() +ax = fig.add_subplot(111) +line, = ax.plot([], [], lw=2) +ax.set_ylim(-1.1, 1.1) +ax.set_xlim(0, 5) +ax.grid() +xdata, ydata = [], [] +def run(data): + # update the data + t,y = data + xdata.append(t) + ydata.append(y) + xmin, xmax = ax.get_xlim() + + if t >= xmax: + ax.set_xlim(xmin, 2*xmax) + ax.figure.canvas.draw() + line.set_data(xdata, ydata) + + return line, + +ani = FuncAnimation(fig, run, data_gen, blit=True, interval=10, repeat=False) +plt.show() Added: trunk/matplotlib/examples/animation/dynamic_image.py =================================================================== --- trunk/matplotlib/examples/animation/dynamic_image.py (rev 0) +++ trunk/matplotlib/examples/animation/dynamic_image.py 2010年08月26日 03:23:25 UTC (rev 8660) @@ -0,0 +1,27 @@ +#!/usr/bin/env python +""" +An animated image +""" +import numpy as np +import matplotlib.pyplot as plt +from animation import FuncAnimation + +fig = plt.figure() + +def f(x, y): + return np.sin(x) + np.cos(y) + +x = np.linspace(0, 2 * np.pi, 120) +y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1) + +im = plt.imshow(f(x, y), cmap=plt.get_cmap('jet')) + +def updatefig(*args): + global x,y + x += np.pi / 15. + y += np.pi / 20. + im.set_array(f(x,y)) + return im, + +ani = FuncAnimation(fig, updatefig, interval=50, blit=True) +plt.show() Added: trunk/matplotlib/examples/animation/dynamic_image2.py =================================================================== --- trunk/matplotlib/examples/animation/dynamic_image2.py (rev 0) +++ trunk/matplotlib/examples/animation/dynamic_image2.py 2010年08月26日 03:23:25 UTC (rev 8660) @@ -0,0 +1,24 @@ +#!/usr/bin/env python +""" +An animated image +""" +import numpy as np +import matplotlib.pyplot as plt +from animation import ArtistAnimation + +fig = plt.figure() + +def f(x, y): + return np.sin(x) + np.cos(y) + +x = np.linspace(0, 2 * np.pi, 120) +y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1) + +ims = [] +for i in range(60): + x += np.pi / 15. + y += np.pi / 20. + ims.append([plt.imshow(f(x, y), cmap=plt.get_cmap('jet'))]) + +ani = ArtistAnimation(fig, ims, interval=50, blit=True, repeat_delay=1000) +plt.show() Added: trunk/matplotlib/examples/animation/histogram.py =================================================================== --- trunk/matplotlib/examples/animation/histogram.py (rev 0) +++ trunk/matplotlib/examples/animation/histogram.py 2010年08月26日 03:23:25 UTC (rev 8660) @@ -0,0 +1,62 @@ +""" +This example shows how to use a path patch to draw a bunch of +rectangles for an animated histogram +""" +import numpy as np + +import matplotlib.pyplot as plt +import matplotlib.patches as patches +import matplotlib.path as path +from animation import FuncAnimation + +fig = plt.figure() +ax = fig.add_subplot(111) + +# histogram our data with numpy +data = np.random.randn(1000) +n, bins = np.histogram(data, 100) + +# get the corners of the rectangles for the histogram +left = np.array(bins[:-1]) +right = np.array(bins[1:]) +bottom = np.zeros(len(left)) +top = bottom + n +nrects = len(left) + +# here comes the tricky part -- we have to set up the vertex and path +# codes arrays using moveto, lineto and closepoly + +# for each rect: 1 for the MOVETO, 3 for the LINETO, 1 for the +# CLOSEPOLY; the vert for the closepoly is ignored but we still need +# it to keep the codes aligned with the vertices +nverts = nrects*(1+3+1) +verts = np.zeros((nverts, 2)) +codes = np.ones(nverts, int) * path.Path.LINETO +codes[0::5] = path.Path.MOVETO +codes[4::5] = path.Path.CLOSEPOLY +verts[0::5,0] = left +verts[0::5,1] = bottom +verts[1::5,0] = left +verts[1::5,1] = top +verts[2::5,0] = right +verts[2::5,1] = top +verts[3::5,0] = right +verts[3::5,1] = bottom + +barpath = path.Path(verts, codes) +patch = patches.PathPatch(barpath, facecolor='green', edgecolor='yellow', alpha=0.5) +ax.add_patch(patch) + +ax.set_xlim(left[0], right[-1]) +ax.set_ylim(bottom.min(), top.max()) + +def animate(i): + # simulate new data coming in + data = np.random.randn(1000) + n, bins = np.histogram(data, 100) + top = bottom + n + verts[1::5,1] = top + verts[2::5,1] = top + +ani = FuncAnimation(fig, animate, 100, repeat=False) +plt.show() Added: trunk/matplotlib/examples/animation/random_data.py =================================================================== --- trunk/matplotlib/examples/animation/random_data.py (rev 0) +++ trunk/matplotlib/examples/animation/random_data.py 2010年08月26日 03:23:25 UTC (rev 8660) @@ -0,0 +1,18 @@ +import numpy as np +import matplotlib.pyplot as plt +from animation import FuncAnimation + +fig = plt.figure() +ax = fig.add_subplot(111) +line, = ax.plot(np.random.rand(10)) +ax.set_ylim(0, 1) + +def update(data): + line.set_ydata(data) + return line, + +def data_gen(): + while True: yield np.random.rand(10) + +ani = FuncAnimation(fig, update, data_gen, interval=100) +plt.show() Added: trunk/matplotlib/examples/animation/simple_3danim.py =================================================================== --- trunk/matplotlib/examples/animation/simple_3danim.py (rev 0) +++ trunk/matplotlib/examples/animation/simple_3danim.py 2010年08月26日 03:23:25 UTC (rev 8660) @@ -0,0 +1,63 @@ +""" +A simple example of an animated plot... In 3D! +""" +import numpy as np +import matplotlib.pyplot as plt +import mpl_toolkits.mplot3d.axes3d as p3 + +from animation import FuncAnimation + +def Gen_RandLine(length, dims=2) : + """ + Create a line using a random walk algorithm + + length is the number of points for the line. + dims is the number of dimensions the line has. + """ + lineData = np.empty((dims, length)) + lineData[:, 0] = np.random.rand(1, dims) + for index in xrange(1, length) : + # scaling the random numbers by 0.1 so + # movement is small compared to position. + # subtraction by 0.5 is to change the range to [-0.5, 0.5] + # to allow a line to move backwards. + step = ((np.random.rand(1, dims) - 0.5) * 0.1) + lineData[:, index] = lineData[:, index-1] + step + + return lineData + +def update_lines(num, dataLines, lines) : + for line, data in zip(lines, dataLines) : + # NOTE: there is no .set_data() for 3 dim data... + line.set_data(data[0:2, :num]) + line.set_3d_properties(data[2,:num]) + return lines + +# Attaching 3D axis to the figure +fig = plt.figure() +ax = p3.Axes3D(fig) + +# Fifty lines of random 3-D lines +data = [Gen_RandLine(25, 3) for index in xrange(50)] + +# Creating fifty line objects. +# NOTE: Can't pass empty arrays into 3d version of plot() +lines = [ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1])[0] for dat in data] + +# Setting the axes properties +ax.set_xlim3d([0.0, 1.0]) +ax.set_xlabel('X') + +ax.set_ylim3d([0.0, 1.0]) +ax.set_ylabel('Y') + +ax.set_zlim3d([0.0, 1.0]) +ax.set_zlabel('Z') + +ax.set_title('3D Test') + +# Creating the Animation object +line_ani = FuncAnimation(fig, update_lines, 25, fargs=(data, lines), + interval=50, blit=False) + +plt.show() Added: trunk/matplotlib/examples/animation/simple_anim.py =================================================================== --- trunk/matplotlib/examples/animation/simple_anim.py (rev 0) +++ trunk/matplotlib/examples/animation/simple_anim.py 2010年08月26日 03:23:25 UTC (rev 8660) @@ -0,0 +1,25 @@ +""" +A simple example of an animated plot +""" +import numpy as np +import matplotlib.pyplot as plt +from animation import FuncAnimation + +fig = plt.figure() +ax = fig.add_subplot(111) + +x = np.arange(0, 2*np.pi, 0.01) # x-array +line, = ax.plot(x, np.sin(x)) + +def animate(i): + line.set_ydata(np.sin(x+i/10.0)) # update the data + return line, + +#Init only required for blitting to give a clean slate. +def init(): + line.set_ydata(np.ma.array(x, mask=True)) + return line, + +ani = FuncAnimation(fig, animate, np.arange(1, 200), init_func=init, + interval=25, blit=True) +plt.show() Added: trunk/matplotlib/examples/animation/strip_chart_demo.py =================================================================== --- trunk/matplotlib/examples/animation/strip_chart_demo.py (rev 0) +++ trunk/matplotlib/examples/animation/strip_chart_demo.py 2010年08月26日 03:23:25 UTC (rev 8660) @@ -0,0 +1,49 @@ +""" +Emulate an oscilloscope. Requires the animation API introduced in +matplotlib 1.0 SVN. +""" +import matplotlib +import numpy as np +from matplotlib.lines import Line2D +import matplotlib.pyplot as plt +from animation import FuncAnimation + +class Scope: + def __init__(self, ax, maxt=10, dt=0.01): + self.ax = ax + self.dt = dt + self.maxt = maxt + self.tdata = [0] + self.ydata = [0] + self.line = Line2D(self.tdata, self.ydata) + self.ax.add_line(self.line) + self.ax.set_ylim(-.1, 1.1) + self.ax.set_xlim(0, self.maxt) + + def update(self, y): + lastt = self.tdata[-1] + if lastt > self.tdata[0] + self.maxt: # reset the arrays + self.tdata = [self.tdata[-1]] + self.ydata = [self.ydata[-1]] + self.ax.set_xlim(self.tdata[0], self.tdata[0] + self.maxt) + + t = self.tdata[-1] + self.dt + self.tdata.append(t) + self.ydata.append(y) + self.line.set_data(self.tdata, self.ydata) + return self.line, + +def emitter(p=0.01): + 'return a random value with probability p, else 0' + while True: + v = np.random.rand(1) + if v > p: + yield 0. + else: + yield np.random.rand(1) + +fig = plt.figure() +ax = fig.add_subplot(111) +scope = Scope(ax) +ani = FuncAnimation(fig, scope.update, emitter, interval=10, blit=True) +plt.show() Added: trunk/matplotlib/examples/animation/subplots.py =================================================================== --- trunk/matplotlib/examples/animation/subplots.py (rev 0) +++ trunk/matplotlib/examples/animation/subplots.py 2010年08月26日 03:23:25 UTC (rev 8660) @@ -0,0 +1,93 @@ +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.lines import Line2D +from animation import TimedAnimation + +# This example uses subclassing, but there is no reason that the proper function +# couldn't be set up and then use FuncAnimation. The code is long, but not +# really complex. The length is due solely to the fact that there are a total +# of 9 lines that need to be changed for the animation as well as 3 subplots +# that need initial set up. +class SubplotAnimation(TimedAnimation): + def __init__(self): + fig = plt.figure() + ax1 = fig.add_subplot(1, 2, 1) + ax2 = fig.add_subplot(2, 2, 2) + ax3 = fig.add_subplot(2, 2, 4) + + self.t = np.linspace(0, 80, 400) + self.x = np.cos(2 * np.pi * self.t / 10.) + self.y = np.sin(2 * np.pi * self.t / 10.) + self.z = 10 * self.t + + ax1.set_xlabel('x') + ax1.set_ylabel('y') + self.line1 = Line2D([], [], color='black') + self.line1a = Line2D([], [], color='red', linewidth=2) + self.line1e = Line2D([], [], color='red', marker='o', markeredgecolor='r') + ax1.add_line(self.line1) + ax1.add_line(self.line1a) + ax1.add_line(self.line1e) + ax1.set_xlim(-1, 1) + ax1.set_ylim(-2, 2) + ax1.set_aspect('equal', 'datalim') + + ax2.set_xlabel('y') + ax2.set_ylabel('z') + self.line2 = Line2D([], [], color='black') + self.line2a = Line2D([], [], color='red', linewidth=2) + self.line2e = Line2D([], [], color='red', marker='o', markeredgecolor='r') + ax2.add_line(self.line2) + ax2.add_line(self.line2a) + ax2.add_line(self.line2e) + ax2.set_xlim(-1, 1) + ax2.set_ylim(0, 800) + + ax3.set_xlabel('x') + ax3.set_ylabel('z') + self.line3 = Line2D([], [], color='black') + self.line3a = Line2D([], [], color='red', linewidth=2) + self.line3e = Line2D([], [], color='red', marker='o', markeredgecolor='r') + ax3.add_line(self.line3) + ax3.add_line(self.line3a) + ax3.add_line(self.line3e) + ax3.set_xlim(-1, 1) + ax3.set_ylim(0, 800) + + TimedAnimation.__init__(self, fig, interval=50, blit=True) + + def _draw_frame(self, framedata): + i = framedata + head = i - 1 + head_len = 10 + head_slice = (self.t > self.t[i] - 1.0) & (self.t < self.t[i]) + + self.line1.set_data(self.x[:i], self.y[:i]) + self.line1a.set_data(self.x[head_slice], self.y[head_slice]) + self.line1e.set_data(self.x[head], self.y[head]) + + self.line2.set_data(self.y[:i], self.z[:i]) + self.line2a.set_data(self.y[head_slice], self.z[head_slice]) + self.line2e.set_data(self.y[head], self.z[head]) + + self.line3.set_data(self.x[:i], self.z[:i]) + self.line3a.set_data(self.x[head_slice], self.z[head_slice]) + self.line3e.set_data(self.x[head], self.z[head]) + + self._drawn_artists = [self.line1, self.line1a, self.line1e, + self.line2, self.line2a, self.line2e, + self.line3, self.line3a, self.line3e] + + def new_frame_seq(self): + return iter(range(self.t.size)) + + def _init_draw(self): + lines = [self.line1, self.line1a, self.line1e, + self.line2, self.line2a, self.line2e, + self.line3, self.line3a, self.line3e] + for l in lines: + l.set_data([], []) + +ani = SubplotAnimation() +#ani.save('test_sub.mp4') +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8663 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8663&view=rev Author: ryanmay Date: 2010年08月26日 03:49:17 +0000 (2010年8月26日) Log Message: ----------- Hide old animation examples under the animation/ subdir. Added Paths: ----------- trunk/matplotlib/examples/animation/old_animation/ Removed Paths: ------------- trunk/matplotlib/examples/old_animation/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.