gnuplotwidthlinelinewidth

gnuplot: why is linewidth 0 not zero in width?


What is the reason that lw 0 doesn't have zero linewidth, i.e. invisible?

What I find in the gnuplot manual:

The line width and point size are multipliers for the current terminal's default width ...

Ok, if lw 0 is a multiplier then the resulting linewidth should be zero independent of the terminal's default linewidth.

The reason for asking is to eventually have the possibility to use with linespoints and programmatically switch within a loop between with lines and with points.

Code:

### linewidth 0 isn't zero
reset session

set key out
set yrange[-0.9:10.9]
set ytics 1

plot for [i=0:10] i with lines lw i title sprintf("linewidth %g",i)

### end of code

Result:

enter image description here

By the way, what are the artefacts at the y-axis e.g. at ytics 3,4,6,7,9,10 (wxt-terminal)?


Solution

  • Mike Nakis is correct that for at least some of the gnuplot output terminals, including PostScript, gnuplot asks for a 0 width line and the language or library in question interprets that as "1 pixel" or "thinnest possible line".

    Similarly "pointtype 0" is not truly missing, it produces a single pixel dot.

    You can, however, disable the line drawing altogether by using linetype "nodraw". That gives a complementary pair of commands

    plot sin(x) with linespoints lt nodraw pt 7         # only the points are visible
    plot sin(x) with linespoints lt 1 pt 0              # only the lines are visible
    

    In some circumstances it may help to know that the numeric equivalent for lt nodraw is lt -2.