Closed as not planned
Closed as not planned
Copy link
Labels
status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.Issues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: confirmed bugstatus: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
Milestone
Description
This is the underlying problem raised in #1178.
It is illustrated by the test below; note that boundary anomalies are visible in all forms--agg on the screen, and pdf and svg displayed with a viewer--but in different places depending on the viewer and the size of the figure as rendered.
Note that the colorbar is rendered using pcolormesh, which has its own renderer with agg but otherwise is handled by draw_path_collection.
import numpy as np
import matplotlib.pyplot as plt
z = np.arange(150)
z.shape = (10,15)
fig, axs = plt.subplots(2,2)
ax = axs[0,0]
cs0 = ax.contourf(z, 20)
cbar0 = fig.colorbar(cs0, ax=ax)
ax = axs[0,1]
cs1 = ax.contourf(z, 20, alpha=0.3)
cbar1 = fig.colorbar(cs1, ax=ax)
ax = axs[1,0]
im2 = ax.imshow(z, interpolation='nearest')
cbar2 = fig.colorbar(im2, ax=ax)
ax = axs[1,1]
im3 = ax.imshow(z, interpolation='nearest', alpha=0.3)
cbar3 = fig.colorbar(im3, ax=ax)
plt.savefig("test1.pdf")
plt.savefig("test1.svg")
plt.show()
Metadata
Metadata
Assignees
Labels
status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.Issues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: confirmed bugstatus: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
Activity
dmcdougall commentedon Sep 1, 2012
If you start the code block with ```python you'll get some syntax highlighting.
jenshnielsen commentedon Sep 2, 2012
To me it seems like the pdf backend draws them correctly without addition edges however some viewers render these incorrectly and adds some white space. In the agg backend however even without edges there is an overlap between the paths visible only when alpha is less than 1. I guess this is an unrelated bug in the agg drawing code. It is correctly called with no edges. The pngs from the cairo backends are drawn without any overlap. However it does seem like this backend does not support alpha for imshow. I will open a separate issue for this.
jenshnielsen commentedon Sep 2, 2012
The pdf problem in evince is probably equivalent to this one
https://bugs.launchpad.net/ubuntu/+source/poppler/+bug/318130
which was reported in 2009
jenshnielsen commentedon Sep 2, 2012
Indeed the pdf problem in evince is fixed by applying the patch to poppler linked to in that bug report (0001-Align-fills-to-device-integer-coordinates.patch) so it seems like an aliasing problem.
Colorbar Add kw arguement to colorbar to reenable edges around faces in
Add documentation of colorbar issue matplotlib#1188 to colorbar docum…
Merge pull request #1315 from jenshnielsen/colorbar_issuedoc
dmcdougall commentedon Sep 28, 2012
Did we decide that this is a viewer problem? If so, should this be closed as it requires an upstream fix?
jenshnielsen commentedon Sep 28, 2012
No there is another issue. The agg backend still renders the colorbar with overlap like the pdf did
before meaning that the colorbar with alpha < 1 will look wrong in png. Furthermore alpha is ignored for images (#1193) in the cairo backend so it is not actually possible to render png colorbars with alpha < 1 correctly.
dmcdougall commentedon Sep 28, 2012
@jenshnielsen Thanks for clarifying.
awehrfritz commentedon Feb 3, 2015
Is there still somebody looking into this one? I'm using matplotlib 1.4.2 (linux-x64) and still get these white stripes in the colorbar or contourf plots.
I tested the pdf-files with various readers, i.e. okular (libpoppler), google-chrome, Adobe Reader/Acrobat XI (both Windows), and always see these stripes.
Interestingly, for the ps-files the issue is less pronounced but I would say still present.
The svg-files also have the same issue as the pdf-files.
The stripes almost disappear when I plot the same data twice (see the script below), but I consider this as a very bad workaround.
The only fix that works consistently is to set
edgecolor="face", but I guess that was also regarded as a workaround and not a fix.Here is a script that shows how to reproduce and work around the white stripes for contourf plots and the colorbar. I hope it helps to debug and fix this problem.
jenshnielsen commentedon Feb 3, 2015
As far as I understand this is a bug in the pdf renders which there is very little we can do about. If you draw 2 faces next to each other with no overlap a gab will often show due roundoff/snapping (Adobe seems to handle this better than most others in my tests).
We can't draw them with an overlap in general since that would break partially transparent contours with alpha< 1. Try adding alpha=0.5 to all your contourf calls to see what I mean i.e
ax.contourf(X,Y,Z, 50, cmap='gnuplot', alpha=0.5)and so on.Using
edgecolor='face'is a workaround which adds a small border to all faces. The border gives an non zero overlap which looks strange when alpha<1 but is otherwise perfectly fine. I would consider that a way better solution than plotting the data twice.17 remaining items
jklymak commentedon Aug 27, 2021
@godot11 I cannot reproduce this on 3.4.2, so maybe upgrade? If you still have problems, please open a new issue with your explicit save command specified.
godot11 commentedon Aug 27, 2021
Oops, seems it was indeed matplotlib. It slipped my eyes that I did a conda update wrongly before I posted.
In case it may help here's my conda update output:
conda update log
github-actions commentedon Feb 27, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
gkatev commentedon Feb 27, 2023
Re: github-actions, this is still present in 3.6.3.
jklymak commentedon Feb 27, 2023
@gkatev Can you tell us exactly what is still present? This thread has many different issues.
gkatev commentedon Feb 27, 2023
Hi, yes, sorry for being vague. Below is where the issue is exhibited for me -- please let me know if it's not relevant.
This script reproduces the issue. Use this dataset: data.txt
The resulting svg file has unexpected white lines between the cells (viewing it in eog or in firefox).
QuLogic commentedon Feb 27, 2023
I know I assigned this ages ago, but I'm planning to work on it for 3.8. Though at the moment, I don't know that there is any way to fix SVG.
jklymak commentedon Feb 27, 2023
I think this is really hard to fix. This is basically the same issue as with contours and arises because it is impossible to anti-alias properly: https://github.com/jklymak/contourfIssues. If you make your svg viewer not anti-alias this problem goes away. However, I really suggest rasterizing the pcolor. It can make for larger files, but pdf/svg viewers are pretty efficient at dealing with images in the svg.
I actually think this should be closed as "can't fix", but maybe someone has a solution.
QuLogic commentedon Feb 27, 2023
The original post is about all formats, and at least Agg and PDF can be fixed.
github-actions commentedon Feb 28, 2024
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!