From: Eric F. <ef...@ha...> - 2005-02-25 18:57:23
|
John, > Eric> Having solved that problem, I am getting more optimistic > Eric> about being able to come up with a usable filled contour > Eric> capability fairly quickly. Still no promises, though. > > Great -- be mindful of the contourf matlab docstrings. Strict > adherence is not required, but it is nice to be compatible where > possible. I have the basic filled contour functionality working, with the following caveats, comments, and questions: 0) I've done only the simplest of testing so far. 1) There is a fundamental difference in strategy between Matlab's contour patch generation algorithm and gcntr.c: Matlab makes all patches as simply connected regions without branch cuts, but gcntr polygons have branch cuts. This means that we can't use the polygon edges; if one wants line contours at the contour levels, they must be drawn separately, by asking gcntr for lines, as contour does. My inclination is to leave it this way: the user can simply call contourf to get the filled regions, and then call contour to add lines as needed. Typically I draw lines at only a few of the color boundaries, and sometimes I draw additional lines within colored regions, so this is the way I normally use matlab contourf and contour anyway. 2) In the present version, there is much too much duplication of code between contour and contourf in axes.py; I copied the contour function to contourf, modified what I needed to, and moved only the ContourMappable class out to the module level. I would like to factor out more of the common code. 3) The docstrings in axes.py are driving me nuts--lacking proper indentation, they make it very difficult to find the function definitions. I presume this is because of the way boilerplate.py is generating the pylab.py functions and their docstrings. I haven't looked at boilerplate.py (I haven't used it yet at all), but I suspect it would be easy to change things so that it would handle properly indented docstrings. Is it OK if I do this? 4) ToDo: it is not standard in matlab, but for filled contouring I always use a matching colorbar--essentially a colorbar contoured with the same levels and colors as the contour plot itself, rather than one that shows the whole colormap. 5) ToDo: I haven't tried to do anything with region masking yet; maybe I will get to it soon, since it is something I need. 5) gcntr.c uses global variables, which presumably means that it will fail if called from more than one thread at a time. Longer term, should I/we/someone modify it so that this not the case? Or is this characteristic of other routines used by matplotlib, so there is no point in worrying about gcntr.c in particular? 6) When the time comes to send you my modifications, how should I do it: diffs, or complete files? Send to you directly, or to the list? If you would prefer diffs, please give me an example of the exact diff command options to use. (I am working with matplotlib-0.72.1 as a starting point.) Modified files will include axes.py, pylab.py (and/or boilerplate.py), _contour.c, and an example. Eric |