contourf creats white-like lines (or gaps) between each two color patches

When I use contourf to plot a filled contour map, I get some white-like lines
between each two color patches, or you can call them gaps.
This is not like the contourf doc string says: "it does not draw the
polygon edges.", actually, it does.
http://old.nabble.com/file/p27982822/contourf1.png contourf1.png
The figure above is what I get by contourf, but this is not exactlly what I
want.

The filled contour map I want should be like this one:
http://old.nabble.com/file/p27982822/contourf2.png contourf2.png

Any advice?

Thank you!

···

--
View this message in context: http://old.nabble.com/contourf-creats-white-like-lines-(or-gaps)-between-each-two-color-patches-tp27982822p27982822.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Actually, it does not draw the polygon edges, but leaves small gaps between them. Through those gaps you can see the background. (This also happens with polar plots and other polygons by the way.) I consider this a bug, though there are ways around it. For contour plots one can plot two contourplots over each other, one with different levels (or a different number of levels) than the other. Messy, but it works.

Marius.

lmkli wrote:

···

When I use contourf to plot a filled contour map, I get some white-like lines
between each two color patches, or you can call them gaps.
This is not like the contourf doc string says: "it does not draw the
polygon edges.", actually, it does.
http://old.nabble.com/file/p27982822/contourf1.png contourf1.png The figure above is what I get by contourf, but this is not exactlly what I
want.

The filled contour map I want should be like this one:
http://old.nabble.com/file/p27982822/contourf2.png contourf2.png

Any advice?

Thank you!

Thank you!

I just thought there must be a solution.
I saw someone posted he can modified contour.py to fix this, but I failed.
:frowning:

Marius 't Hart-3 wrote:

···

Actually, it does not draw the polygon edges, but leaves small gaps
between them. Through those gaps you can see the background. (This also
happens with polar plots and other polygons by the way.) I consider this
a bug, though there are ways around it. For contour plots one can plot
two contourplots over each other, one with different levels (or a
different number of levels) than the other. Messy, but it works.

Marius.

lmkli wrote:

When I use contourf to plot a filled contour map, I get some white-like
lines
between each two color patches, or you can call them gaps.
This is not like the contourf doc string says: "it does not draw the
polygon edges.", actually, it does.
http://old.nabble.com/file/p27982822/contourf1.png contourf1.png
The figure above is what I get by contourf, but this is not exactlly what
I
want.

The filled contour map I want should be like this one:
http://old.nabble.com/file/p27982822/contourf2.png contourf2.png

Any advice?

Thank you!
  
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://old.nabble.com/contourf-creats-white-like-lines-(or-gaps)-between-each-two-color-patches-tp27982822p27996271.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

lmkli wrote:

Thank you!

I just thought there must be a solution.
I saw someone posted he can modified contour.py to fix this, but I failed.
:frowning:

What version of mpl are you using? Are you modifying the default anti-aliasing in the patch collections that contour is creating? Are you seeing the problem when using the ps and pdf backends, or only with agg (that is, creating png files directly)?

There are two problems that can contribute to this, one related to the way the agg backend handles the boundaries between filled regions, and the other a bug in path simplification, which has been fixed in svn.

Eric

···

Marius 't Hart-3 wrote:

Actually, it does not draw the polygon edges, but leaves small gaps between them. Through those gaps you can see the background. (This also happens with polar plots and other polygons by the way.) I consider this a bug, though there are ways around it. For contour plots one can plot two contourplots over each other, one with different levels (or a different number of levels) than the other. Messy, but it works.

Marius.

lmkli wrote:

When I use contourf to plot a filled contour map, I get some white-like
lines
between each two color patches, or you can call them gaps.
This is not like the contourf doc string says: "it does not draw the
polygon edges.", actually, it does.
http://old.nabble.com/file/p27982822/contourf1.png contourf1.png The figure above is what I get by contourf, but this is not exactlly what
I
want.

The filled contour map I want should be like this one:
http://old.nabble.com/file/p27982822/contourf2.png contourf2.png

Any advice?

Thank you!
  
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

What version of mpl are you using?

My mpl version is 0.99.1

Are you modifying the default anti-aliasing in the patch collections that
contour is creating?

Could you please tell me how to this? I am very new to matplotlib, thank you
very much if you can give me some advices.

Are you seeing the problem when using the ps and pdf backends, or only with

agg (that is, creating png files directly)?
So far I only creating png files directly. Also, how to use ps and pdf
backend?

....which has been fixed in svn.

Do you mean I should download another mpl by svn?

Thank you for your answers very much!

efiring wrote:

···

What version of mpl are you using? Are you modifying the default
anti-aliasing in the patch collections that contour is creating? Are you
seeing the problem when using the ps and pdf backends, or only with agg
(that is, creating png files directly)?

There are two problems that can contribute to this, one related to the
way the agg backend handles the boundaries between filled regions, and
the other a bug in path simplification, which has been fixed in svn.

Eric

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://old.nabble.com/contourf-creats-white-like-lines-(or-gaps)-between-each-two-color-patches-tp27982822p28210898.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

lmkli wrote:

What version of mpl are you using?

My mpl version is 0.99.1

Are you modifying the default anti-aliasing in the patch collections that
contour is creating?

Could you please tell me how to this? I am very new to matplotlib, thank you
very much if you can give me some advices.

see below.

Are you seeing the problem when using the ps and pdf backends, or only with

agg (that is, creating png files directly)?
So far I only creating png files directly. Also, how to use ps and pdf
backend?

The easiest way is with the pyplot savefig command: e.g.

savefig("test.pdf")

to save the current figure as a pdf.

It doesn't look to me like this solves the problem, though.

....which has been fixed in svn.

Do you mean I should download another mpl by svn?

That might help, but it probably won't cure the problem completely. I don't know that there is any combination of parameters that gives boundaries as smooth and gap-free as in your second example. You may get a bit closer to it like this:

CS = contourf(Z)
for c in CS.collections:
     c.set_antialiased(False)

(If working interactively in ipython, follow this with a "draw()" command to force a redraw.)

Eric

···

Thank you for your answers very much!

efiring wrote:

What version of mpl are you using? Are you modifying the default anti-aliasing in the patch collections that contour is creating? Are you seeing the problem when using the ps and pdf backends, or only with agg (that is, creating png files directly)?

There are two problems that can contribute to this, one related to the way the agg backend handles the boundaries between filled regions, and the other a bug in path simplification, which has been fixed in svn.

Eric

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

CS = contourf(Z)
for c in CS.collections:
    c.set_antialiased(False)

Eric,
Thank you! I like this very much!
So, the last thing is, is there any way to set this antialiased feature to
False by default?

efiring wrote:

···

lmkli wrote:

What version of mpl are you using?

My mpl version is 0.99.1

Are you modifying the default anti-aliasing in the patch collections
that
contour is creating?

Could you please tell me how to this? I am very new to matplotlib, thank
you
very much if you can give me some advices.

see below.

Are you seeing the problem when using the ps and pdf backends, or only
with

agg (that is, creating png files directly)?
So far I only creating png files directly. Also, how to use ps and pdf
backend?

The easiest way is with the pyplot savefig command: e.g.

savefig("test.pdf")

to save the current figure as a pdf.

It doesn't look to me like this solves the problem, though.

....which has been fixed in svn.

Do you mean I should download another mpl by svn?

That might help, but it probably won't cure the problem completely. I
don't know that there is any combination of parameters that gives
boundaries as smooth and gap-free as in your second example. You may
get a bit closer to it like this:

CS = contourf(Z)
for c in CS.collections:
     c.set_antialiased(False)

(If working interactively in ipython, follow this with a "draw()"
command to force a redraw.)

Eric

Thank you for your answers very much!

efiring wrote:

What version of mpl are you using? Are you modifying the default
anti-aliasing in the patch collections that contour is creating? Are you
seeing the problem when using the ps and pdf backends, or only with agg
(that is, creating png files directly)?

There are two problems that can contribute to this, one related to the
way the agg backend handles the boundaries between filled regions, and
the other a bug in path simplification, which has been fixed in svn.

Eric

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://old.nabble.com/contourf-creats-white-like-lines-(or-gaps)-between-each-two-color-patches-tp27982822p28219132.html
Sent from the matplotlib - users mailing list archive at Nabble.com.