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

Skip to content

Commit 69696d7

Browse files
committed
added frameon for figure
svn path=/trunk/matplotlib/; revision=312
1 parent ee3bedd commit 69696d7

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

TODO

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,8 @@
392392

393393
-- DONE image data scaling
394394

395-
-- y tick outside frame?
395+
-- DONE y tick outside frame?
396+
397+
-- incorporate gary's errorbar
398+
399+
-- bug in -45 newline text

examples/mri_with_eeg.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from __future__ import division
77
from matplotlib.matlab import *
88
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
1011
# I use if 1 to break up the different regions of code visually
1112

1213
if 1: # load the data
@@ -42,25 +43,31 @@
4243

4344
height = 72 # height of one EEG in pixels
4445
# transform data to axes coord (0,1)
45-
transy = Transform(Bound1D(-.05,.05), Bound1D(-.2,.2))
46+
47+
4648
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)
5150
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+
5460
ax.add_line(thisLine)
5561
ticklocs.append(offset)
5662

5763
set(gca(), 'xlim', [0,10])
64+
set(gca(), 'ylim', [0,200])
5865
set(gca(), 'xticks', arange(10))
5966
yticks = set(gca(), 'yticks', ticklocs)
6067
set(gca(), 'yticklabels', ['PG3', 'PG5', 'PG7', 'PG9'])
6168

6269
# set the yticks to use axes coords on the y axis
63-
set(yticks, 'transform', ax.yaxis.transAxis)
70+
set(yticks, 'transform', ax.transAxes)
6471
xlabel('time (s)')
6572

6673

src/_transforms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,12 @@ Transformation::numerix_x_y(const Py::Tuple & args) {
554554
Py::Object xo = args[0];
555555
Py::Object yo = args[1];
556556

557-
PyArrayObject *x = (PyArrayObject *) PyArray_FromObject(xo.ptr(), PyArray_DOUBLE, 1, 1);
557+
PyArrayObject *x = (PyArrayObject *) PyArray_ContiguousFromObject(xo.ptr(), PyArray_DOUBLE, 1, 1);
558558

559559
if (x==NULL)
560560
throw Py::TypeError("Transformation::numerix_x_y expected numerix array");
561561

562-
PyArrayObject *y = (PyArrayObject *) PyArray_FromObject(yo.ptr(), PyArray_DOUBLE, 1, 1);
562+
PyArrayObject *y = (PyArrayObject *) PyArray_ContiguousFromObject(yo.ptr(), PyArray_DOUBLE, 1, 1);
563563

564564
if (y==NULL)
565565
throw Py::TypeError("Transformation::numerix_x_y expected numerix array");

0 commit comments

Comments
 (0)