@@ -563,6 +563,45 @@ external backend via the ``module`` directive. if
563563
564564.. _license-discussion :
565565
566+
567+ Writing examples
568+ ================
569+
570+ We have hundreds of examples in subdirectories of
571+ file:`matplotlib/examples ` in the trunk, and these are automatically
572+ generated when the website it built to show up both in the `examples
573+ <http://matplotlib.sourceforge.net/examples/index.html> `_ and `gallery
574+ <http://matplotlib.sourceforge.net/gallery.html> `_ sections of the
575+ website. Many people find these examples from the website, and do not
576+ have ready access to the file:`examples ` directory in which they
577+ reside. Thus any example data that is required for the example should
578+ be provided through the sample_data svn directory, which can then be
579+ accessed using :func: `matplotlib.cbook.get_sample_data `. First get a
580+ copy of the repository and svn add your data::
581+
582+ svn co http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/sample_data
583+ cp ~/path/to/mydata.dat sample_data/
584+ cd sample_data
585+ svn add mydata.dat
586+ svn commit -m 'added my data'
587+
588+ and then in your example code you can load it into a file handle with::
589+
590+ import matplotlib.cbook as cbook
591+ fh = cbook.get_sample_data('mydata.dat')
592+
593+ The file will be fetched from the svn repo using urllib and updated
594+ when the revision number changes.
595+
596+
597+ If you prefer just to get the full path to the file instead of an file
598+ object::
599+
600+ import matplotlib.cbook as cbook
601+ datafile = cbook.get_sample_data('mydata.dat', asfileobj=False)
602+ print 'datafile', datafile
603+
604+
566605Licenses
567606========
568607
@@ -630,3 +669,4 @@ The other reason is licensing compatibility with the other python
630669extensions for scientific computing: ipython, numpy, scipy, the
631670enthought tool suite and python itself are all distributed under BSD
632671compatible licenses.
672+ >
0 commit comments