|
6 | 6 | from __future__ import division
|
7 | 7 | from pylab import *
|
8 | 8 | from matplotlib.lines import Line2D
|
9 |
| -from matplotlib.transforms import get_bbox_transform, Point, Value, Bbox,\ |
10 |
| - unit_bbox |
11 |
| - |
| 9 | +from matplotlib.transforms import Bbox, BboxTransform, BboxTransformTo, Affine2D |
12 | 10 |
|
13 | 11 | # I use if 1 to break up the different regions of code visually
|
14 | 12 |
|
|
36 | 34 |
|
37 | 35 | if 1: # plot the EEG
|
38 | 36 | # load the data
|
| 37 | + |
39 | 38 | numSamples, numRows = 800,4
|
40 | 39 | data = fromstring(file('data/eeg.dat', 'rb').read(), float)
|
41 | 40 | data.shape = numSamples, numRows
|
42 | 41 | t = arange(numSamples)/float(numSamples)*10.0
|
43 | 42 | ticklocs = []
|
44 | 43 | ax = subplot(212)
|
| 44 | + xlim(0,10) |
| 45 | + xticks(arange(10)) |
45 | 46 |
|
46 |
| - boxin = Bbox( |
47 |
| - Point(ax.viewLim.ll().x(), Value(-20)), |
48 |
| - Point(ax.viewLim.ur().x(), Value(20))) |
49 |
| - |
50 |
| - |
51 |
| - height = ax.bbox.ur().y() - ax.bbox.ll().y() |
52 |
| - boxout = Bbox( |
53 |
| - Point(ax.bbox.ll().x(), Value(-1)*height), |
54 |
| - Point(ax.bbox.ur().x(), Value(1) * height)) |
| 47 | + boxin = Bbox.from_extents(ax.viewLim.x0, -20, ax.viewLim.x1, 20) |
55 | 48 |
|
| 49 | + height = ax.bbox.height |
| 50 | + boxout = Bbox.from_extents(ax.bbox.x0, -1.0 * height, |
| 51 | + ax.bbox.x1, 1.0 * height) |
56 | 52 |
|
57 |
| - transOffset = get_bbox_transform( |
58 |
| - unit_bbox(), |
59 |
| - Bbox( Point( Value(0), ax.bbox.ll().y()), |
60 |
| - Point( Value(1), ax.bbox.ur().y()) |
61 |
| - )) |
| 53 | + transOffset = BboxTransformTo( |
| 54 | + Bbox.from_extents(0.0, ax.bbox.y0, 1.0, ax.bbox.y1)) |
62 | 55 |
|
63 | 56 |
|
64 | 57 | for i in range(numRows):
|
65 | 58 | # effectively a copy of transData
|
66 |
| - trans = get_bbox_transform(boxin, boxout) |
| 59 | + trans = BboxTransform(boxin, boxout) |
67 | 60 | offset = (i+1)/(numRows+1)
|
68 | 61 |
|
69 |
| - trans.set_offset( (0, offset), transOffset) |
| 62 | + trans += Affine2D().translate(*transOffset.transform_point((0, offset))) |
70 | 63 |
|
71 | 64 | thisLine = Line2D(
|
72 | 65 | t, data[:,i]-data[0,i],
|
|
77 | 70 | ax.add_line(thisLine)
|
78 | 71 | ticklocs.append(offset)
|
79 | 72 |
|
80 |
| - xlim(0,10) |
81 |
| - xticks(arange(10)) |
82 |
| - |
83 | 73 | setp(gca(), 'yticklabels', ['PG3', 'PG5', 'PG7', 'PG9'])
|
84 | 74 |
|
85 | 75 | # set the yticks to use axes coords on the y axis
|
|
0 commit comments