Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting line width increases line length

166 views
Skip to first unread message

Ivan K.

unread,
Feb 17, 2013, 9:03:53 PM2/17/13
to
Appended below are a command file and two simple data files
which illustrate a problem that I am having with
setting the width of a plotted line.

In the example, both lines begin at x=10
and end at x=20.

However, in the top line, I have set the line
width to "7" but not only does this increase
the width of the line (something I want)
but increasing the width increases the _length_
of the line too (something I do not want).

In the example, even though the data for
both lines begins at x=10 and ends at x=20, the
top line is longer.


Can I increase the width of a line without
increasing the length?

Thank you for your help;



::::::::::::: line_width_01.com :::::::::::::

set term pngcairo enhanced size 400, 200

set output 'line_width_01.png';
set nokey;
set origin 0.0, 0.0;

plot [ 0 :30 ][ 0: 50 ] \
'line_width_01_01.dat' with lines lw 1, \
'line_width_01_02.dat' with lines lw 7

::::::::::::: line_width_01_01.dat :::::::::::::

10 23
20 23


::::::::::::: line_width_01_02.dat :::::::::::::

10 27
20 27

sfeam

unread,
Feb 18, 2013, 1:23:16 PM2/18/13
to
Ivan K. wrote:
> However, in the top line, I have set the line
> width to "7" but not only does this increase
> the width of the line (something I want)
> but increasing the width increases the _length_
> of the line too (something I do not want).

You are referring to the treatment of line segment ends
("end caps"). The options are conventionally called "butt",
"square", and "round". See here, for example:

http://i.stack.imgur.com/xCRe3.png

Gnuplot's pngcairo terminal lets you choose between
"butt" or "round". "square" is not currently supported.
It sounds like you want
set terminal pngcairo butt

Ivan K.

unread,
Feb 18, 2013, 1:33:54 PM2/18/13
to
Hello Mr. Sfeam. Thank you for your response.

Just before you posted that, I found the page:

http://gnuplot.10905.n7.nabble.com/bug-or-feature-td12930.html

which addresses this exact issue. Based on
this page, like your suggestion, I changed:

set term pngcairo enhanced size 400, 200

to:

set term png enhanced butt size 400, 200

that is, I added "butt" to the "set term" command.
I also changed "pngcairo" to "png" as the option "butt"
did nothing to the resulting image with "pngcairo".


HOWEVER, this solution only "sort of " works
as there is now a weird artifact at the beginning of
each line. Obviously, I would like to get rid of
this artifact.

Thank you very much for your help;

:::::::::::::: line_width_02.com ::::::::::::::

set term png enhanced butt size 400, 200

set output 'line_width_02.png';
set nokey;
set origin 0.0, 0.0;

plot [ 0 :30 ][ 0: 50 ] \
'line_width_02_01.dat' w l lt 1 lw 1, \
'line_width_02_02.dat' w l lt 1 lw 7, \
'line_width_02_03.dat' w l lt 1 lw 11, \
'line_width_02_04.dat' w l lt 1 lw 15

:::::::::::::: line_width_02_01.dat ::::::::::::::
10 40
20 40

:::::::::::::: line_width_02_02.dat ::::::::::::::
10 30
20 30

:::::::::::::: line_width_02_03.dat ::::::::::::::
10 20
20 20

:::::::::::::: line_width_02_04.dat ::::::::::::::
10 10
20 10

Ivan K.

unread,
Feb 18, 2013, 1:51:14 PM2/18/13
to

sfeam

unread,
Feb 18, 2013, 2:05:07 PM2/18/13
to
Ivan K. wrote:

> Just before you posted that, I found the page:
>
> http://gnuplot.10905.n7.nabble.com/bug-or-feature-td12930.html
>
> which addresses this exact issue. Based on
> this page, like your suggestion, I changed:
>
> set term pngcairo enhanced size 400, 200
>
> to:
>
> set term png enhanced butt size 400, 200
>
> that is, I added "butt" to the "set term" command.
> I also changed "pngcairo" to "png" as the option "butt"
> did nothing to the resulting image with "pngcairo".

Yes. I had forgotten that the cairo terminal interprets
"butt" on the command line as "square" internally.
The Nabble page you link to explains this clearly.
Unfortunately the suggestion given there that additional line
options could appear in gnuplot 4.6 was not implemented.
It should go back on a wishlist for gnuplot 5.

So I'm afraid that gnuplot does not provide the detailed
control over individual line properties that you want.
If you choose an output mode that can be further edited
(notably PostScript or SVG) then you could tweak the
result in an external tool like Acrobat or Inkscape.
It is also possible that you could customize your locally
installed PostScript prologue files to set your preferred
line attributes by default in gnuplot.

Ethan

Ivan K.

unread,
Feb 18, 2013, 2:12:37 PM2/18/13
to

On Feb 18, 1:05 pm, sfeam <sf...@users.sourceforge.net> wrote:
>
> Unfortunately the suggestion given there that additional line
> options could appear in gnuplot 4.6 was not implemented.
> It should go back on a wishlist for gnuplot 5.

How does one go about officially putting this on the list
for future implementation?


> So I'm afraid that gnuplot does not provide the detailed
> control over individual line properties that you want.

I am dismayed.


Thank you Ethan for your expert knowledge of
gnuplot and your willingness to share!

Ivan K.

unread,
Feb 18, 2013, 2:17:30 PM2/18/13
to

Hey, it works with "term svg":

set term svg enhanced butt size 400, 200

It still would be nice if it worked with "term png" though.

Thanks.

0 new messages