Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 600dc21

Browse files
committed
Fix mri_with_eeg example
svn path=/branches/transforms/; revision=4500
1 parent 21cf88d commit 600dc21

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

examples/mri_with_eeg.py

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
from __future__ import division
77
from pylab import *
88
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
1210

1311
# I use if 1 to break up the different regions of code visually
1412

@@ -36,37 +34,32 @@
3634

3735
if 1: # plot the EEG
3836
# load the data
37+
3938
numSamples, numRows = 800,4
4039
data = fromstring(file('data/eeg.dat', 'rb').read(), float)
4140
data.shape = numSamples, numRows
4241
t = arange(numSamples)/float(numSamples)*10.0
4342
ticklocs = []
4443
ax = subplot(212)
44+
xlim(0,10)
45+
xticks(arange(10))
4546

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)
5548

49+
height = ax.bbox.height
50+
boxout = Bbox.from_extents(ax.bbox.x0, -1.0 * height,
51+
ax.bbox.x1, 1.0 * height)
5652

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))
6255

6356

6457
for i in range(numRows):
6558
# effectively a copy of transData
66-
trans = get_bbox_transform(boxin, boxout)
59+
trans = BboxTransform(boxin, boxout)
6760
offset = (i+1)/(numRows+1)
6861

69-
trans.set_offset( (0, offset), transOffset)
62+
trans += Affine2D().translate(*transOffset.transform_point((0, offset)))
7063

7164
thisLine = Line2D(
7265
t, data[:,i]-data[0,i],
@@ -77,9 +70,6 @@
7770
ax.add_line(thisLine)
7871
ticklocs.append(offset)
7972

80-
xlim(0,10)
81-
xticks(arange(10))
82-
8373
setp(gca(), 'yticklabels', ['PG3', 'PG5', 'PG7', 'PG9'])
8474

8575
# set the yticks to use axes coords on the y axis

0 commit comments

Comments
 (0)