|
From: <jd...@us...> - 2009-08-05 16:21:38
|
Revision: 7382
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7382&view=rev
Author: jdh2358
Date: 2009-08-05 16:21:23 +0000 (Wed, 05 Aug 2009)
Log Message:
-----------
removed examples/data; ported all examples to use sample_data
Modified Paths:
--------------
trunk/matplotlib/examples/api/watermark_image.py
trunk/matplotlib/examples/pylab_examples/date_index_formatter.py
trunk/matplotlib/examples/pylab_examples/image_demo2.py
trunk/matplotlib/examples/pylab_examples/image_demo3.py
trunk/matplotlib/examples/pylab_examples/load_converter.py
trunk/matplotlib/examples/pylab_examples/loadrec.py
trunk/matplotlib/examples/pylab_examples/logo.py
trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py
trunk/matplotlib/examples/pylab_examples/plotfile_demo.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
Added Paths:
-----------
trunk/sample_data/ct.raw
trunk/sample_data/data_x_x2_x3.csv
trunk/sample_data/demodata.csv
trunk/sample_data/eeg.dat
trunk/sample_data/embedding_in_wx3.xrc
trunk/sample_data/lena.jpg
trunk/sample_data/logo2.png
trunk/sample_data/membrane.dat
trunk/sample_data/msft.csv
trunk/sample_data/s1045.ima
Removed Paths:
-------------
trunk/matplotlib/examples/data/
Modified: trunk/matplotlib/examples/api/watermark_image.py
===================================================================
--- trunk/matplotlib/examples/api/watermark_image.py 2009-08-05 16:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/api/watermark_image.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -4,11 +4,13 @@
import numpy as np
import matplotlib
matplotlib.use('Agg')
-
+import matplotlib.cbook as cbook
import matplotlib.image as image
import matplotlib.pyplot as plt
-im = image.imread('../data/logo2.png')
+datafile = cbook.get_sample_data('logo2.png', asobj=False)
+print 'loading', datafile
+im = image.imread(datafile)
im[:,:,-1] = 0.5 # set the alpha channel
fig = plt.figure()
Modified: trunk/matplotlib/examples/pylab_examples/date_index_formatter.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/date_index_formatter.py 2009-08-05 16:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/pylab_examples/date_index_formatter.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -11,9 +11,12 @@
import numpy
from matplotlib.mlab import csv2rec
from pylab import figure, show
+import matplotlib.cbook as cbook
from matplotlib.ticker import Formatter
-r = csv2rec('../data/msft.csv')[-40:]
+datafile = cbook.get_sample_data('msft.csv', asobj=False)
+print 'loading', datafile
+r = csv2rec(datafile)[-40:]
class MyFormatter(Formatter):
def __init__(self, dates, fmt='%Y-%m-%d'):
Modified: trunk/matplotlib/examples/pylab_examples/image_demo2.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/image_demo2.py 2009-08-05 16:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/pylab_examples/image_demo2.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -2,7 +2,10 @@
from pylab import *
w, h = 512, 512
-s = file('../data/ct.raw', 'rb').read()
+
+datafile = cbook.get_sample_data('ct.raw', asobj=False)
+print 'loading', datafile
+s = file(datafile, 'rb').read()
A = fromstring(s, uint16).astype(float)
A *= 1.0/max(A)
A.shape = w, h
Modified: trunk/matplotlib/examples/pylab_examples/image_demo3.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/image_demo3.py 2009-08-05 16:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/pylab_examples/image_demo3.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -5,7 +5,8 @@
except ImportError, exc:
raise SystemExit("PIL must be installed to run this example")
-lena = Image.open('../data/lena.jpg')
+datafile = cbook.get_sample_data('lena.jpg')
+lena = cbook.Image.open(datafile)
dpi = rcParams['figure.dpi']
figsize = lena.size[0]/dpi, lena.size[1]/dpi
Modified: trunk/matplotlib/examples/pylab_examples/load_converter.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/load_converter.py 2009-08-05 16:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/pylab_examples/load_converter.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -2,9 +2,13 @@
#from matplotlib.mlab import load
import numpy as np
from pylab import figure, show
+import matplotlib.cbook as cbook
+datafile = cbook.get_sample_data('msft.csv', asobj=False)
+print 'loading', datafile
+
dates, closes = np.loadtxt(
- '../data/msft.csv', delimiter=',',
+ datafile, delimiter=',',
converters={0:strpdate2num('%d-%b-%y')},
skiprows=1, usecols=(0,2), unpack=True)
Modified: trunk/matplotlib/examples/pylab_examples/loadrec.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/loadrec.py 2009-08-05 16:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/pylab_examples/loadrec.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -1,7 +1,10 @@
from matplotlib import mlab
from pylab import figure, show
+import matplotlib.cbook as cbook
-a = mlab.csv2rec('../data/msft.csv')
+datafile = cbook.get_sample_data('msft.csv', asobj=False)
+print 'loading', datafile
+a = mlab.csv2rec(datafile)
a.sort()
print a.dtype
Modified: trunk/matplotlib/examples/pylab_examples/logo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/logo.py 2009-08-05 16:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/pylab_examples/logo.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -4,8 +4,10 @@
# convert data to mV
-x = 1000*0.1*fromstring(
- file('../data/membrane.dat', 'rb').read(), float32)
+datafile = cbook.get_sample_data('membrane.dat', asobj=False)
+print 'loading', datafile
+
+x = 1000*0.1*fromstring(file(datafile, 'rb').read(), float32)
# 0.0005 is the sample interval
t = 0.0005*arange(len(x))
figure(1, figsize=(7,1), dpi=100)
Modified: trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py 2009-08-05 16:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -9,12 +9,13 @@
from matplotlib.pyplot import *
from matplotlib.collections import LineCollection
-
+import matplotlib.cbook as cbook
# I use if 1 to break up the different regions of code visually
if 1: # load the data
# data are 256x256 16 bit integers
- dfile = '../data/s1045.ima'
+ dfile = cbook.get_sample_data('s1045.ima', asfileobj=False)
+ print 'loading image', dfile
im = np.fromstring(file(dfile, 'rb').read(), np.uint16).astype(float)
im.shape = 256, 256
@@ -38,7 +39,9 @@
# load the data
numSamples, numRows = 800,4
- data = np.fromstring(file('../data/eeg.dat', 'rb').read(), float)
+ eegfile = cbook.get_sample_data('eeg.dat', asfileobj=False)
+ print 'loading eeg', eegfile
+ data = np.fromstring(file(eegfile, 'rb').read(), float)
data.shape = numSamples, numRows
t = 10.0 * np.arange(numSamples, dtype=float)/numSamples
ticklocs = []
Modified: trunk/matplotlib/examples/pylab_examples/plotfile_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/plotfile_demo.py 2009-08-05 16:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/pylab_examples/plotfile_demo.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -1,7 +1,8 @@
from pylab import plotfile, show, gca
+import matplotlib.cbook as cbook
-fname = '../data/msft.csv'
-fname2 = '../data/data_x_x2_x3.csv'
+fname = cbook.get_sample_data('msft.csv', asobj=False)
+fname2 = cbook.get_sample_data('data_x_x2_x3.csv', asobj=False)
# test 1; use ints
plotfile(fname, (0,5,6))
Modified: trunk/matplotlib/examples/user_interfaces/embedding_in_wx3.py
===================================================================
--- trunk/matplotlib/examples/user_interfaces/embedding_in_wx3.py 2009-08-05 16:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/user_interfaces/embedding_in_wx3.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -27,6 +27,7 @@
import matplotlib
matplotlib.use('WXAgg')
import matplotlib.cm as cm
+import matplotlib.cbook as cbook
from matplotlib.backends.backend_wxagg import Toolbar, FigureCanvasWxAgg
from matplotlib.figure import Figure
import numpy as npy
@@ -101,8 +102,9 @@
class MyApp(wx.App):
def OnInit(self):
- xrcfile = os.path.join(os.path.dirname(__file__),"..","data",
- "embedding_in_wx3.xrc")
+ xrcfile = cbook.get_sample_data('embedding_in_wx3.xrc', asobj=False)
+ print 'loading', xrcfile
+
self.res = xrc.XmlResource(xrcfile)
# main frame and panel ---------
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:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_custom.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -6,11 +6,14 @@
import gtk
import numpy as np
import matplotlib.mlab as mlab
+import matplotlib.cbook as cbook
import mpl_toolkits.gtktools as gtktools
-r = mlab.csv2rec('data/demodata.csv', converterd={'weekdays':str})
+datafile = cbook.get_sample_data('demodata.csv', asobj=False)
+r = mlab.csv2rec(datafile, converterd={'weekdays':str})
+
formatd = mlab.get_formatd(r)
formatd['date'] = mlab.FormatDate('%Y-%m-%d')
formatd['prices'] = mlab.FormatMillions(precision=1)
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:05:38 UTC (rev 7381)
+++ trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_simple.py 2009-08-05 16:21:23 UTC (rev 7382)
@@ -5,9 +5,11 @@
import gtk
import numpy as np
import matplotlib.mlab as mlab
+import matplotlib.cbook as cbook
import mpl_toolkits.gtktools as gtktools
-r = mlab.csv2rec('data/demodata.csv', converterd={'weekdays':str})
+datafile = cbook.get_sample_data('demodata.csv', asobj=False)
+r = mlab.csv2rec(datafile, converterd={'weekdays':str})
liststore, treeview, win = gtktools.edit_recarray(r)
win.set_title('click to edit')
Copied: trunk/sample_data/ct.raw (from rev 7377, trunk/matplotlib/examples/data/ct.raw)
===================================================================
--- trunk/sample_data/ct.raw (rev 0)
+++ trunk/sample_data/ct.raw 2009-08-05 16:21:23 UTC (rev 7382)
@@ -0,0 +1,2352 @@
+ |