Question

I'm now trying to use filledcurve in gnuplot 4.6, patchlevel 1. Following shows the sample script:

set term epslatex
set output "figure.tex"

set xlabel "\\huge{x-axis}"
set ylabel "\\huge{y-axis}"
set format xy "\\LARGE{%.0f}"
set xrange [0.0:10.0]
set yrange [0.0:100.0]
set xtics 2.0
set ytics 20.0
set xtics offset 0, -0.3

f1(x) = x**1
f2(x) = x**2
f3(x) = x**3

set nokey
plot '+' using 1:(f2($1)):(f3($1)) with filledcurve lt 1 lc rgb "gray60",\
     '+' using 1:(f1($1)):(f2($1)) with filledcurve lt 1 lc rgb "gray40",\
     '+' using 1:(0.0):(f1($1))    with filledcurve lt 1 lc rgb "gray20"

I don't known why, but it seems that there are white annoying slits between bars. It cannot be get rid of even if I increase the number of set samples.

Is there any idea to remove these slits?

enter image description here

Was it helpful?

Solution

Unfortunately, this is a viewer problem related to the drawing of adjacent filled polygons, see also problematic Moire pattern in image produced with gnuplot pm3d and pdf output or the bug report #1259 cairolatex pdf fill patterns.

In your case you can use a workaround:

When you have only two columns in the using statement, the area is drawn as closed polygon and doesn't show these artifacts (filledcurves closed). So you must fill the area between each curve and the x1 axis (with filledcurves x1).

Because of a bug in the clipping of curves which exceed the y-range, you must do the clipping of the f3 curve yourself (i.e. use f3($1) > 100 ? 100 : f3($1)). This bug is fixed in the development version.

So you script is:

set term epslatex standalone
set output "figure.tex"

set xlabel "\\huge x-axis"
set ylabel "\\huge y-axis"
set format xy "\\LARGE %.0f"
set xrange [0.0:10.0]
set yrange [0.0:100.0]
set xtics 2.0
set ytics 20.0
set xtics offset 0, -0.3

f1(x) = x**1
f2(x) = x**2
f3(x) = x**3

set nokey
plot '+' using 1:(f3($1) > 100 ? 100 : f3($1)) with filledcurve x1 lt 1 lc rgb "gray60",\
     '+' using 1:(f2($1)) with filledcurve x1 lt 1 lc rgb "gray40",\
     '+' using 1:(f1($1)) with filledcurve x1 lt 1 lc rgb "gray20"

set output
system('latex figure.tex && dvips figure.dvi && ps2pdf figure.ps')

with the result (using 4.6.1):

enter image description here

Note also, that LaTeX commands like \huge don't take arguments, but are switches. Test e.g. \huge{A}BC, this will make all letter huge. Usually you must limit the scope of \huge with brackets like {\huge ABC}, but if the whole label is affected, it is enough to use set xlabel "\\huge x-axis". That doesn't change anything in your case, but may give you troubles in other circumstances :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top