|
6 | 6 | from __future__ import division |
7 | 7 | from matplotlib.matlab import * |
8 | 8 | from matplotlib.lines import Line2D |
9 | | -from matplotlib.transforms import Transform, Bound1D |
| 9 | +from matplotlib.transforms import get_bbox_transform, Point, Value, Bbox,\ |
| 10 | + translation_transform, zero |
10 | 11 | # I use if 1 to break up the different regions of code visually |
11 | 12 |
|
12 | 13 | if 1: # load the data |
|
42 | 43 |
|
43 | 44 | height = 72 # height of one EEG in pixels |
44 | 45 | # transform data to axes coord (0,1) |
45 | | - transy = Transform(Bound1D(-.05,.05), Bound1D(-.2,.2)) |
| 46 | + |
| 47 | + |
46 | 48 | for i in range(numRows): |
47 | | - thisLine = Line2D( |
48 | | - ax.dpi, ax.bbox, t, data[:,i]-data[0,i], |
49 | | - transx=ax.xaxis.transData, |
50 | | - transy=transy) |
| 49 | + trans = get_bbox_transform(ax.viewLim, ax.bbox) |
51 | 50 | offset = (i+1)/(numRows+1) |
52 | | - thisLine.set_vertical_offset(offset, ax.yaxis.transAxis) |
53 | | - |
| 51 | + height = Value(offset) * (ax.bbox.ur().y() - ax.bbox.ll().y()) |
| 52 | + trans.set_offset( (0,0), translation_transform(zero(), height) ) |
| 53 | + |
| 54 | + thisLine = Line2D( |
| 55 | + t, data[:,i]-data[0,i], |
| 56 | + ) |
| 57 | + |
| 58 | + thisLine.set_transform(trans) |
| 59 | + |
54 | 60 | ax.add_line(thisLine) |
55 | 61 | ticklocs.append(offset) |
56 | 62 |
|
57 | 63 | set(gca(), 'xlim', [0,10]) |
| 64 | + set(gca(), 'ylim', [0,200]) |
58 | 65 | set(gca(), 'xticks', arange(10)) |
59 | 66 | yticks = set(gca(), 'yticks', ticklocs) |
60 | 67 | set(gca(), 'yticklabels', ['PG3', 'PG5', 'PG7', 'PG9']) |
61 | 68 |
|
62 | 69 | # set the yticks to use axes coords on the y axis |
63 | | - set(yticks, 'transform', ax.yaxis.transAxis) |
| 70 | + set(yticks, 'transform', ax.transAxes) |
64 | 71 | xlabel('time (s)') |
65 | 72 |
|
66 | 73 |
|
|
0 commit comments