SF.net SVN: matplotlib: [3904] trunk/matplotlib
Revision: 3904
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3904&view=rev
Author: efiring
Date: 2007-10-01 00:06:43 -0700 (Mon, 01 Oct 2007)
Log Message:
---
Fixed bug in updating dataLim when an axis is reversed
Modified Paths:
--
trunk/matplotlib/CHANGELOG
trunk/matplotlib/src/_transforms.cpp
Modified: trunk/matplotlib/CHANGELOG
===
--- trunk/matplotlib/CHANGELOG 2007-09-30 20:47:55 UTC (rev 3903)
+++ trunk/matplotlib/CHANGELOG 2007-10-01 07:06:43 UTC (rev 3904)
@@ -1,3 +1,10 @@
+2007-09-30 Modified update* methods of Bbox and Interval so they
+ work with reversed axes. Prior to this, trying to
+ set the ticks on a reversed axis failed with an
+ uninformative error message. - EF
+
+2007-09-30 Applied patches to axes3d to fix index error problem - EF
+
2007-09-24 Applied Eike Welk's patch reported on mpl-dev on 2007-09-22
Fixes a bug with multiple plot windows in the qt backend,
ported the changes to backend_qt4 as well - DSD
@@ -2,3 +9,3 @@
-2007-09-21 Changed cbook.reversed to yield the same result as the
+2007-09-21 Changed cbook.reversed to yield the same result as the
python reversed builtin - DSD
Modified: trunk/matplotlib/src/_transforms.cpp
===
--- trunk/matplotlib/src/_transforms.cpp2007-09-30 20:47:55 UTC (rev
3903)
+++ trunk/matplotlib/src/_transforms.cpp2007-10-01 07:06:43 UTC (rev
3904)
@@ -159,12 +159,19 @@
double minx = _val1->val();
double maxx = _val2->val();
+ int reversed = 0;
+ if (minx > maxx) {
+reversed = 1;
+double tmp = minx;
+minx = maxx;
+maxx = tmp;
+ }
double thisval;
thisval = Py::Float(vals[0]);
- if (ignore) {
+ if (ignore) {
minx = thisval;
maxx = thisval;
}
@@ -176,9 +183,13 @@
_minpos->update(thisval);
}
-
- _val1->set_api(minx);
- _val2->set_api(maxx);
+ if (reversed) {
+_val1->set_api(maxx);
+_val2->set_api(minx);
+ } else {
+_val1->set_api(minx);
+_val2->set_api(maxx);
+ }
return Py::Object();
}
@@ -459,8 +470,24 @@
double minx = _ll->xval();
double maxx = _ur->xval();
+ int xreversed = 0;
+ if (minx > maxx) {
+xreversed = 1;
+double tmp = minx;
+minx = maxx;
+maxx = tmp;
+ }
+
+
double miny = _ll->yval();
double maxy = _ur->yval();
+ int yreversed = 0;
+ if (miny > maxy) {
+yreversed = 1;
+double tmp = miny;
+miny = maxy;
+maxy = tmp;
+ }
Py::Tuple tup;
if (ignore) {
@@ -482,11 +509,22 @@
if (y>maxy) maxy=y;
}
+ if (xreversed) {
+_ll->x_api()->set_api(maxx);
+_ur->x_api()->set_api(minx);
+ } else {
+_ll->x_api()->set_api(minx);
+_ur->x_api()->set_api(maxx);
+ }
- _ll->x_api()->set_api(minx);
- _ll->y_api()->set_api(miny);
- _ur->x_api()->set_api(maxx);
- _ur->y_api()->set_api(maxy);
+ if (yreversed) {
+_ll->y_api()->set_api(maxy);
+_ur->y_api()->set_api(miny);
+ } else {
+_ll->y_api()->set_api(miny);
+_ur->y_api()->set_api(maxy);
+ }
+
return Py::Object();
}
@@ -519,8 +557,24 @@
double minx = _ll->xval();
double maxx = _ur->xval();
+ int xreversed = 0;
+ if (minx > maxx) {
+xreversed = 1;
+double tmp = minx;
+minx = maxx;
+maxx = tmp;
+ }
+
+
double miny = _ll->yval();
double maxy = _ur->yval();
+ int yreversed = 0;
+ if (miny > maxy) {
+yreversed = 1;
+double tmp = miny;
+miny = maxy;
+maxy = tmp;
+ }
double thisx, thisy;
//don't use current bounds on first update
@@ -550,10 +604,21 @@
Py_XDECREF(xyin);
if (ngood) {
-_ll->x_api()->set_api(minx);
-_ll->y_api()->set_api(miny);
-_ur->x_api()->set_api(maxx);
-_ur->y_api()->set_api(maxy);
+if (xreversed) {
+ _ll->x_api()->set_api(maxx);
+ _ur->x_api()->set_api(minx);
+} else {
+ _ll->x_api()->set_api(minx);
+ _ur->x_api()->set_api(maxx);
+}
+
+if (yreversed) {
+ _ll->y_api()->set_api(maxy);
+ _ur->y_api()->set_api(miny);
+} else {
+ _ll->y_api()->set_api(miny);
+ _ur->y_api()->set_api(maxy);
+}
}
return Py::Object();
}
@@ -594,8 +659,24 @@
double minx = _ll->xval();
double maxx = _ur->xval();
+ int xreversed = 0;
+ if (minx > maxx) {
+xreversed = 1;
+double tmp = minx;
+minx = maxx;
+maxx = tmp;
+ }
+
+
double miny = _ll->yval();
double maxy = _ur->yval();
+ int yreversed = 0;
+ if (miny > maxy) {
+yreversed = 1;
+double tmp = miny;
+miny = maxy;
+maxy = tmp;
+ }
double thisx, thisy;
//don't use current bounds on first update
@@ -627,10 +708,21 @@
Py_XDECREF(y);
- _ll->x_api()->set_api(minx);
- _ll->y_api()->set_api(miny);
- _ur->x_api()->set_api(maxx);
- _ur->y_api()->set_api(maxy);
+ if (xreversed) {
+_ll->x_ap
SF.net SVN: matplotlib: [3906] branches/transforms
Revision: 3906 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3906&view=rev Author: mdboom Date: 2007-10-01 04:53:52 -0700 (Mon, 01 Oct 2007) Log Message: --- Merged revisions 3896-3905 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib r3898 | jdh2358 | 2007-09-28 08:41:08 -0400 (Fri, 28 Sep 2007) | 2 lines fixed some tick accessor bugs r3899 | jouni | 2007-09-28 11:50:01 -0400 (Fri, 28 Sep 2007) | 3 lines Catch UnboundLocalError in checkdep_pdftops; it is raised if no output line of pdftops -v contains the word "version". r3900 | jouni | 2007-09-28 11:57:49 -0400 (Fri, 28 Sep 2007) | 2 lines More debugging output when using TeX with the pdf backend r3901 | jouni | 2007-09-30 16:08:50 -0400 (Sun, 30 Sep 2007) | 3 lines use_tex in pdf backend: don't use AFM files, which are not there in some TeX distros r3902 | efiring | 2007-09-30 16:32:31 -0400 (Sun, 30 Sep 2007) | 4 lines bugfix by Zack, confirmed by Gary Ruben. http://sourceforge.net/mailarchive/forum.php?thread_name=d8cf9020703071339y43354eaerbfa1a47d272e5d26%40mail.gmail.com&forum_name=matplotlib-users r3903 | efiring | 2007-09-30 16:47:55 -0400 (Sun, 30 Sep 2007) | 2 lines Apply patch by Leon Barrett, tracker #1798196 r3904 | efiring | 2007-10-01 03:06:43 -0400 (Mon, 01 Oct 2007) | 2 lines Fixed bug in updating dataLim when an axis is reversed Modified Paths: -- branches/transforms/CHANGELOG branches/transforms/lib/matplotlib/__init__.py branches/transforms/lib/matplotlib/axes3d.py branches/transforms/lib/matplotlib/axis.py branches/transforms/lib/matplotlib/backends/backend_pdf.py branches/transforms/lib/matplotlib/dviread.py branches/transforms/lib/matplotlib/widgets.py Property Changed: branches/transforms/ Property changes on: branches/transforms ___ Name: svnmerge-integrated - /trunk/matplotlib:1-3895 + /trunk/matplotlib:1-3905 Modified: branches/transforms/CHANGELOG === --- branches/transforms/CHANGELOG 2007-10-01 11:44:54 UTC (rev 3905) +++ branches/transforms/CHANGELOG 2007-10-01 11:53:52 UTC (rev 3906) @@ -1,3 +1,10 @@ +2007-09-30 Modified update* methods of Bbox and Interval so they + work with reversed axes. Prior to this, trying to + set the ticks on a reversed axis failed with an + uninformative error message. - EF + +2007-09-30 Applied patches to axes3d to fix index error problem - EF + 2007-09-24 Applied Eike Welk's patch reported on mpl-dev on 2007-09-22 Fixes a bug with multiple plot windows in the qt backend, ported the changes to backend_qt4 as well - DSD @@ -2,3 +9,3 @@ -2007-09-21 Changed cbook.reversed to yield the same result as the +2007-09-21 Changed cbook.reversed to yield the same result as the python reversed builtin - DSD Modified: branches/transforms/lib/matplotlib/__init__.py === --- branches/transforms/lib/matplotlib/__init__.py 2007-10-01 11:44:54 UTC (rev 3905) +++ branches/transforms/lib/matplotlib/__init__.py 2007-10-01 11:53:52 UTC (rev 3906) @@ -270,7 +270,7 @@ v = line.split()[-1] float(v) return v -except (IndexError, ValueError): +except (IndexError, ValueError, UnboundLocalError): return None def compare_versions(a, b): Modified: branches/transforms/lib/matplotlib/axes3d.py === --- branches/transforms/lib/matplotlib/axes3d.py2007-10-01 11:44:54 UTC (rev 3905) +++ branches/transforms/lib/matplotlib/axes3d.py2007-10-01 11:53:52 UTC (rev 3906) @@ -510,16 +510,16 @@ # polys = [] boxes = [] -for rs in npy.arange(0,rows,rstride): -for cs in npy.arange(0,cols,cstride): +for rs in npy.arange(0,rows-1,rstride): +for cs in npy.arange(0,cols-1,cstride): ps = [] corners = [] for a,ta in [(X,tX),(Y,tY),(Z,tZ)]: -ztop = a[rs][cs:min(cols-1,cs+cstride)] +ztop = a[rs][cs:min(cols,cs+cstride+1)] zleft = ta[min(cols-1,cs+cstride)][rs:min(rows,rs+rstride+1)] zbase = a[min(rows-1,rs+rstride)][cs:min(cols,cs+cstride+1):] zbase = zbase[::-1] -zright = ta[cs][rs:min(rows-1,rs+rstride):] +zright = ta[cs][rs:min(rows,rs+rstride+1):] zright = zright[::-1] corners.append([ztop[0],ztop[-1],zbase[0],zbase[-1]]) z = npy.concatenate((zt
