disturbing artifacts in pdf
Asked Answered
D

5

4

I'm struggling with a problem when making plots with filledcurves. Between the filled areas, there seems to be a "gap". However, these artifacts do not appear on the print, but depend on the viewer and zoom-options. In Gnuplot I use the eps terminal, the eps-files look great, but the lines appear when I'm converting to pdf. The conversion it either done directly after plotting or when converting the latex-document from dvi to pdf. As most of the documents are here on the display nowadays, this is an issue. The problem also appears when I'm directly using the pdfcairo terminal in Gnuplot, so it's not caused by the conversion (tried epstopdf and ps2pdf) alone.

I attached a SCREENSHOT of a plot displayed in "acroread" (same problem in other pdf-viewers).

Has anybody an idea how to get rid of it but keeping the graphic vectorized?

vertical lines

Danita answered 3/5, 2012 at 12:6 Comment(0)
A
2

I just ran into the same issue. Apparently the filling between two curves is done as a set of polygons that do not exactly touch one another, thus the thin white lines visible on some PDF viewers.

One way to fix the issue is to draw over these polygon boundaries. First define min and max functions in gnuplot:

min(x, y) = x < y ? x : y
max(x, y) = x > y ? x : y

Then, assuming that column 1 of "datafile" contains your x values and that columns 2 and 3 contain the y values of curves 2 and 3, write:

plot "datafile" using 1:2:3 with filledcurves lc rgb "gray", \
"" using 1:2:(min($2, $3)):(max($2, $3)) with yerrorbars ps 0 lt 1 \
lc rgb "gray" lw 0.5

The first plot instruction fills the spaces between the curves in gray. The second plot instruction draws points of zero size (ps 0) at each x value (1) on curve (2) with thin (lw 0.5), continuous (lt 1), gray (lc rgb "gray"), vertical errorbars (yerrorbars) from the lower to the higher of curves 2 and 3.

This covers the white lines. To get best results you may need to experiment with the thickness of the bars (e.g., lw 0.6, lw 0.2).

Agora answered 28/6, 2015 at 22:3 Comment(0)
B
1

The problem is still present in Gnuplot 5.0.4 and at least the cairolatex terminal which I use to output PDFs. I also wanted to color the area between two curves, in my case defined as functions.

When I used something like

f(x) = 2 + sin(x)
g(x) = cos(x)
plot '+' using 1:(f($1)):(g($1)) with filledcurves closed

I got the same vertical white lines as in the question.

A simple solution for curves where one is always above the other is to let Gnuplot fill the area from the upper curve to the x-axis with the desired color and then paint it over with white from the lower curve downwards:

f(x) = 2 + sin(x)
g(x) = cos(x)
plot f(x) with filledcurves x1, g(x) w filledc x1 fs lc rgb "white"

Apparently this filledcurves style (not between curves but between a curve and an axis) avoids the trapezoid artifacts. This can be readily extended for plotting data files and multiple stacked cures like in the question. Just paint from top to bottom and finish with white for the empty area between the lowest curve and the x-axis.

For overlapping curves a construction of minimum and maximum curves like in the answer from françois-tonneau might do the trick.

Boyd answered 13/1, 2017 at 16:59 Comment(0)
C
1

This issue is fixed with gnuplot 5.2, see https://sourceforge.net/p/gnuplot/patches/749/

The actual problem was, that filled curves were previously plotted as many quadrilaterals, which leads to artifacts (white stripes) in many viewers due to antialiasing.

Since version 5.2 filled curves are rendered as single polygon, which prevents these problems (see issue linked above).

Collincolline answered 3/10, 2017 at 9:45 Comment(0)
L
0

If you're talking about the red and cyan bits the gap could be an illusion caused by the Red + Cyan = White on a RGB screen. Maybe there's no gap, but the border areas appear as white due to the proximity of the pixels.

Take the screenshot and blow it up so you can see the individual pixels around the perceived gap.

If this is the case, maybe selecting a different colour scheme for the adjacent colurs would get rid of the effect. I certainly can't see anything matching your description on anywhere but the red and cyan bits.

Letsou answered 3/5, 2012 at 12:13 Comment(5)
What I mean are the vertical lines, best visible in the grey area. No matter which color they have, I just want a grey area as in the eps graphicsDanita
I don't have a working instance of gnuplot to hand, so I can't really do more to troubleshoot. The answer was just a guess. Try plotting to postscript and take a look at how it actually renders the graphics.Letsou
You might also take a look at it through other PDF readers. There are quite a few OSS ones based on the ghostscript engine. See if the problem occurs across rendering engines.Letsou
After some searching, I came across the following post: groups.google.com/group/comp.graphics.apps.gnuplot/… Apparently it's a well-known problem related to anti-aliasing. There seems to be no work-around at the moment. One could convert the eps to png with "convert +antialias" but this blows up the filesize when converting back to eps.....Danita
@RaphaelRoth - the graphs are largely flat blocks of colour. They should compress quite well with run-length encoding, but won't be as compact as vector representations.Letsou
N
-1

From https://groups.google.com/forum/#!topic/comp.graphics.apps.gnuplot/ivRaKpu5cJ8, it seemed to be a pure Gostscript issue.

Using the eps terminal of Gnuplot and converting the eps file to pdf with

epstopdf -nogs <file.eps> -o <file.pdf>

solved the problem on my system. From the corresponding Man page, the "-nogs" option instructs epstopdf not to use Gostscript.

Naman answered 10/6, 2014 at 9:6 Comment(1)
I tried it and the output file is not a PDF then, I cannot open it with a pdf viewerDanita

© 2022 - 2024 — McMap. All rights reserved.