Joseph Smidt wrote:
I am making contourf plots with some transparency as I want to
eventually overlay such plots. When I plot such plots I see artifacts
or lines that shouldn't be there as seen here:
http://josephsmidt.googlepages.com/ex.png
Is this a bug or am I plotting incorrectly? My script is here:
http://josephsmidt.googlepages.com/plotex.py and the data needed for
the plot is here: http://josephsmidt.googlepages.com/exCHI.txt
However, the relevant part of the code for plotting I'll just cut and
paste here:
levels = [x0, x1, x2, x3]
contourf(Y,X,transpose(CHI),levels,alpha=0.7)
show()
Thanks.
Joseph Smidt
This is a problem with two parts: first, the filled-contour algorithm creates singly-connected patches, so cuts are required (the horizontal lines); second, depending on whether edges are stroked and on the antialias setting, these cuts, and the boundaries between regions, can show up as artifacts when rendered. The rendering problem can be backend-dependent.
When I make a contourf plot using the agg backend (which is presumably what you are using to make the png file--either directly or indirectly via an interactive backend), I am not seeing the artifacts, so I think the default settings in svn are good for agg rendering with alpha. My guess is that you are using a version of mpl with different settings. We have struggled with this problem, trying different combinations of settings, for a long time. There doesn't seem to be a formula that works for all backends and all alpha values.
I suspect that in the version of mpl you are using, the patch edges are being stroked. As a workaround, try this:
cs = contourf(Y,X,transpose(CHI),levels,alpha=0.7)
for c in cs.collections:
c.set_edgecolors(['none'])
Eric