From: John H. <jdh...@ac...> - 2003-12-10 13:29:56
|
>>>>> "Zachary" == Zachary Pincus <zp...@st...> writes: Zachary> Hello - I just posted a few bugs (and patches to fix Zachary> them) to the sourceforge bugtracker page before I Zachary> realized that the email list is preferred. More people see the list I think, but the SF mirror for the dev list is generally woefully out of date, so it's a tossup. Zachary> Short story: I found and (hopefully) fixed a problem with Zachary> pcolor on non-square arrays, a startup error in the Zachary> interactive.py shell, and a problem with repeated output Zachary> when saving postscript backend figures. The details of Zachary> the bugs and patches are copied below. Thanks for the detailed information and patches! Zachary> This happens because the shape of the X and Y arrays (the Zachary> output of a meshgrid call on line 1782) have the wrong Zachary> shape. In particular, the shape is backward. e.g. if Zachary> C.shape = (x,y), then X.shape = Y.shape = (y, x). The behavior of meshgrid certainly is a bit counter-intuitive. Eg, in matlab >> x = [1:7]; >> y = [1:5]; >> [X,Y] = meshgrid(x,y); >> Z = rand(length(x), length(y)); >> pcolor(X,Y,Z); ??? Error using ==> surface Matrix dimensions must agree. matplotlib fails in the same way. I've updated the docs in meshgrid, pcolor and fixed the meshgrid call in the case of pcolor(Z) for nonsquare Z. I added the following to the pcolor docs - let me know if you agree with this. """ Note, the behavior of meshgrid in matlab is a bit counterintuitive for x and y arrays. For example, x = arange(7) y = arange(5) X, Y = meshgrid(x,y) Z = rand( len(x), len(y)) pcolor(X, Y, Z) will fail in matlab and matplotlib. You will probably be happy with pcolor(X, Y, transpose(Z)) Likewise, for nonsquare Z, pcolor(transpose(Z)) will make the x and y axes in the plot agree with the numrows and numcols of Z """ Zachary> Patch: Change matplotlib/axes.py line 1782 from: X, Y = Zachary> meshgrid(range(numRows), range(numCols)) to: X, Y = Zachary> meshgrid(range(numCols), range(numRows)) Done Zachary> (*) Zachary> http://matplotlib.sourceforge.net/matplotlib.mlab.html#-meshgrid Fixed doc bug. Zachary> Patch: Insert the command: interpreter.feed("from Zachary> matplotlib.backends.backend_gtk import ShowOn") somewhere Zachary> before line 206. Fixed -- I don't know how this got removed. Zachary> Patch: Insert the following lines at the end of the Zachary> print_figure method of the FigurePS class in the file Zachary> matplotlib/ backends/backend_ps.py (line 189): Zachary> self._pswriter = StringIO() Zachary> self._pswriter.write(_psHeader) Added a flush method, called by __init__ and after writing the figure. Thanks again -- that was very helpful. John Hunter |