1

I'm plotting (using pcolormesh) some colourmap figures to be added to my report written in Latex. I hope to save the figure as pdf so that I could use vector graphics in my report and Latex is happy to read pdf.

However, the saved figure shows white lines (which I assume are tiny gaps) separating the pixels. When I save it as png, it looks fine. I'm wondering if it's possible to make the pdf looks like the png one.

pdf

png

L L
  • 31
  • 5
  • 2
    Does this answer your question? [White lines in matplotlib's pcolor](https://stackoverflow.com/questions/27092991/white-lines-in-matplotlibs-pcolor) – yut23 Apr 21 '23 at 22:39

1 Answers1

1

This is a known problem with exporting slabs or strips of gradient colours as they are boundaried areas. Here is Acrobat plug-in within MS Edge (no way to control visually) enter image description here

The viewers in some cases can compensate for the vector display by means of blending the edges. Here the difference in the viewer is achieved by simply pressing A for "Anti-Alias", but several setting may or may not be present depending on viewer.

enter image description here

From https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-there-unwanted-borders

Acrobat Reader (cross platform) There are options in Preferences to enable/disable text smoothing, image smoothing and line art smoothing. Disable line art smoothing.

Preview (macOS) There is an option in Preferences to enable/disable anti-aliasing of text and line art. Disable this option.

GSview (cross platform) There are settings for Text Alpha and Graphics Alpha. Change Graphics Alpha from 4 bits to 1 bit to disable graphic anti-aliasing.

gv (Unix-like X) There is an option to enable/disable anti-aliasing. Disable this option.

Evince (Linux/GNOME) There is not an option to disable anti-aliasing in this viewer.

Okular (Linux/KDE) There is not an option in the GUI to enable/disable anti-aliasing. From a console command line, use: $ kwriteconfig --file okularpartrc --group 'Dlg Performance'
--key GraphicsAntialias Disabled Then restart Okular. Change the final word to ‘Enabled’ to restore the original setting.

And I can confirm there is NO configuration setting in SumatraPDF even though based on MuPDF
enter image description here

Even if a viewer compensates for those blocks, it may still have problems with other boundaries where stroking is "none", see top right of this zoomed in section. if a line is present in a PDF it is expected to be displayed at given width, but you cannot say a pdf pixel is zero dimension.

enter image description here

Workaround

Importing a bitmap (which will on import to PDF be converted from PNG) is one way to fix pixel dimensions at a scale.

K J
  • 8,045
  • 3
  • 14
  • 36