jake
jake

Reputation: 351

Set point size independent of line weight

I have the following line styles defined in gnuplot:

set linetype 1 lc rgb "red" lw 3 pt 7
set linetype 3 lc rgb "red" lw 1 pt 7

It appears as though the points derive part of their size from the lineweight. I'm using these styles inside of a plot for loop with linetype cycle using the same style for a cspline and the corresponding points, so I don't see any easy way to just define a separate style for the points.

I get results like this: different size points

The points respond to pointsize but the point in linetype 1 is still slightly larger (presumably from the thicker border).

Is it possible to get the points in these two styles to be the same size?

In response to Miguel's comment, a more complete example of my use case is:

filenames = "A B C D"

set linetype 1 lc rgb "blue"        lw 3 pt 7
set linetype 2 lc rgb "red"         lw 3 pt 7
set linetype 3 lc rgb "blue"        lw 1 pt 7
set linetype 4 lc rgb "red"         lw 1 pt 7
set linetype cycle 4

plot for [file in filenames] file.".csv" \
     using 1:2
     title file \
     smooth csplines, \
     for [file in filenames] file.".csv" \
     u 1:2 with points notitle

linetypes 5-8 get set by the cycling and are used by the last part of the plotting command. Recommendations on another way to do this would be welcome!

Upvotes: 2

Views: 725

Answers (2)

Miguel
Miguel

Reputation: 7627

For your very specific case you can set more styles, and do it rather automatically with a do for loop (reusing your code):

filenames = "A B C D"

do for [i=0:1] {
set linetype (4*i+1) lc rgb "blue"        lw (i == 1 ? 0 : 3) pt 7
set linetype (4*i+2) lc rgb "red"         lw (i == 1 ? 0 : 3) pt 7
set linetype (4*i+3) lc rgb "blue"        lw (i == 1 ? 0 : 1) pt 7
set linetype (4*i+4) lc rgb "red"         lw (i == 1 ? 0 : 1) pt 7
}
set linetype cycle 8

plot for [file in filenames] file.".csv" \
     using 1:2 \
     title file \
     smooth csplines, \
     for [file in filenames] file.".csv" \
     u 1:2 with points notitle

With some simple data files:

enter image description here

Upvotes: 2

Christoph
Christoph

Reputation: 48430

For some terminals the size of filled point types depends on the linewidth because they have a border. This is the case for all cairo-based terminals (pdfcairo, pngcairo, wxt and cairolatex), whereas other terminal like svg, postscript, qt don't show this behaviour.

As test case consider

set linetype 1 lc rgb "red" lw 3 pt 7
set linetype 3 lc rgb "red" lw 1 pt 7

set samples 11
set style function linespoints
plot x lt 1, x + 0.5 lt 3

Considering that you want to have the linepoints samples in the legend, you're best choice is to reduce the point size a bit for the line type with the larger linewidth, like

set linetype 1 lc rgb "red" lw 3 pt 7 ps 0.9

The choice of the scaling factor must be determined manually.

Upvotes: 1

Related Questions