From: <ef...@us...> - 2007-10-01 07:06:44
|
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.cpp 2007-09-30 20:47:55 UTC (rev 3903) +++ trunk/matplotlib/src/_transforms.cpp 2007-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_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(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |