Yannick Copin wrote:
> Hi,
> 
> running the simple test code:
> 
> from pylab import *
> X, Y = meshgrid(linspace(-3,3,11),linspace(-3,3,11))
> Z = randn(*X.shape)
> lev = linspace(Z.min(),Z.max(),11)[1:-1]
> contourf(X,Y,Z, lev, extend='both')
> contour(X,Y,Z, lev, colors='k')
> show()
> 
> you will probably notice that the 'contourf' contours are not always 
> exactly the sames as the 'contour' contours. Why is it so? Don't contour 
> and contourf use the same contour constructor?

The same overall routine is used for contour as for contourf, but the 
contour tracing operation is not identical.  Tracing a filled contour is 
much more complicated--that is probably why it is so hard to find filled 
contour routines.  I suspect that whoever wrote the original code we are 
using wrote the line contour version first, then had to add quite a bit 
of logic and code to get it to make filled contours.

Now, you may be wondering why we can't simply use the boundary of the 
filled regions for the lines as well, to guarantee they are the same. 
The reason is that filled contour boundaries include cuts connecting 
inner and outer contours, and also inner boundaries (edges of masked 
regions--except when affected by a bug) and the outer boundaries of the 
domain).  It might be possible to simply exclude those line segments 
from the line contours, but it is not clear to me that the effort would 
be well-spent.

I think that the differences illustrated in your example will occur 
almost entirely in pathologically ambiguous cases, but it is also 
possible that they reflect actual bugs or shortcomings of the algorithms 
used.  Understanding the logic and tracing the code path in the present 
cntr.c is difficult; I have tried but failed to figure out and correct 
the interior masked region bug in contourf.  If a better core contour 
routine with a suitable license could be found and substituted for the 
present one, that would be very nice.  I have searched many times 
without turning anything up.

Eric

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to