|
From: Allin C. <cot...@wf...> - 2010-03-07 00:30:06
|
I'm trying to plot "recessions bars" (i.e. shaded vertical bars indicating peak-to-trough of a recession) on an economic time series graph. I can get roughly the right effect by doing: set style line 6 lc rgb "#dddddd" lw 30 set style increment user set arrow from 1980.5,1600 to 1980.0,3400 nohead back lt 6 plot <data> (where the y-range is 1600 to 3400). But the problem is that setting the linewidth to 30 (to represent the duration of the recession) also causes the ends of the lines to be extended, top and bottom, so they spill out of the graph area. (For terms = png, pngcairo, pdfcairo, at least.) My first reaction is that setting a fat linewidth should not affect the length of the line, but is there some reason why it does so? (Or maybe a better question is, is there a better way of doing what I'm trying to do?) Allin Cottrell |
|
From: Ethan M. <merritt@u.washington.edu> - 2010-03-07 01:40:08
|
On Saturday 06 March 2010, Allin Cottrell wrote:
> But the problem is that
> setting the linewidth to 30 (to represent the duration of the
> recession) also causes the ends of the lines to be extended, top
> and bottom, so they spill out of the graph area. (For terms = png,
> pngcairo, pdfcairo, at least.)
>
> My first reaction is that setting a fat linewidth should not
> affect the length of the line, but is there some reason why it
> does so?
This is the convention established by PostScript and followed by
many other vector-drawing languages. Lines are drawn as if by
a pen with a flat, round, or square nib. In the latter two cases
each line segment is extended by the radius of the nib.
The corresponding PostScript commands are {0|1|2} setlinecap.
The corresponding cairo properties are BUTT, ROUND, and SQUARE.
Gnuplot's "set terminal" commands accept "rounded" and "butt" as options.
Confusingly, the cairo terminal's "butt" option is translated into
CAIRO_LINE_CAP_SQUARE rather than CAIRO_LINE_CAP_BUTT.
This can be considered a bug :-)
Anyhow, for postscript and for the libgd-based png terminal you should be
able to get what you want by saying, for example,
set term png butt
For the cairo terminals, it seems a bit late in the day to change
things for 4.4.0 but we can look at it after the release. Probably
we should expose all three options to the user. We could do that
for post.trm also.
Ethan
> (Or maybe a better question is, is there a better way of doing
> what I'm trying to do?)
|
|
From: Allin C. <cot...@wf...> - 2010-03-07 03:18:33
|
On Sat, 6 Mar 2010, Ethan Merritt wrote:
> On Saturday 06 March 2010, Allin Cottrell wrote:
>
> > But the problem is that
> > setting the linewidth to 30 (to represent the duration of the
> > recession) also causes the ends of the lines to be extended, top
> > and bottom, so they spill out of the graph area. (For terms = png,
> > pngcairo, pdfcairo, at least.)
> >
> > My first reaction is that setting a fat linewidth should not
> > affect the length of the line, but is there some reason why it
> > does so?
>
> This is the convention established by PostScript and followed by
> many other vector-drawing languages. Lines are drawn as if by
> a pen with a flat, round, or square nib. In the latter two cases
> each line segment is extended by the radius of the nib.
> The corresponding PostScript commands are {0|1|2} setlinecap.
> The corresponding cairo properties are BUTT, ROUND, and SQUARE.
>
> Gnuplot's "set terminal" commands accept "rounded" and "butt" as options.
> Confusingly, the cairo terminal's "butt" option is translated into
> CAIRO_LINE_CAP_SQUARE rather than CAIRO_LINE_CAP_BUTT.
>
> This can be considered a bug :-)
>
> Anyhow, for postscript and for the libgd-based png terminal you should be
> able to get what you want by saying, for example,
> set term png butt
Thanks, and Yes, I get that with libgd-png. In fact I get no
spillover with "set term post eps" (without adding "butt") but the
appearance of the gray bar is not good: it has horizontal stripes.
However, I've come to a better way to control the recession bars,
namely by adding the peaks and troughs as data and plotting them
using 1:2:3 with filledcurve.
Allin Cottrell
|
|
From: sfeam (E. Merritt) <eam...@gm...> - 2010-03-07 03:24:44
|
On Saturday 06 March 2010, Allin Cottrell wrote: > > Anyhow, for postscript and for the libgd-based png terminal you should be > > able to get what you want by saying, for example, > > set term png butt > > Thanks, and Yes, I get that with libgd-png. In fact I get no > spillover with "set term post eps" (without adding "butt") "Butt" is the default for the PostScript terminals. > but the > appearance of the gray bar is not good: it has horizontal stripes. That may be a defect in your viewer rather than in the postscript output. If you are viewing in ghostview or gv, try turning off the anti-aliasing. Ethan |
|
From: Allin C. <cot...@wf...> - 2010-03-07 03:35:09
|
On Sat, 6 Mar 2010, sfeam (Ethan Merritt) wrote: > On Saturday 06 March 2010, Allin Cottrell wrote: > > > Anyhow, for postscript and for the libgd-based png terminal you should be > > > able to get what you want by saying, for example, > > > set term png butt > > > > Thanks, and Yes, I get that with libgd-png. In fact I get no > > spillover with "set term post eps" (without adding "butt") > > "Butt" is the default for the PostScript terminals. Ah, OK. But then shouldn't that be consistent across terminals? > > but the > > appearance of the gray bar is not good: it has horizontal stripes. > > That may be a defect in your viewer rather than in the postscript > output. If you are viewing in ghostview or gv, try turning off > the anti-aliasing. It may be the viewer (gv) but toggling anti-aliasing doesn't make any difference, and it looks stripey at all magnifications. Allin Cottrell |
|
From: sfeam (E. Merritt) <eam...@gm...> - 2010-03-07 03:44:21
|
On Saturday 06 March 2010, Allin Cottrell wrote: > > On Sat, 6 Mar 2010, sfeam (Ethan Merritt) wrote: > > > On Saturday 06 March 2010, Allin Cottrell wrote: > > > > Anyhow, for postscript and for the libgd-based png terminal you should be > > > > able to get what you want by saying, for example, > > > > set term png butt > > > > > > Thanks, and Yes, I get that with libgd-png. In fact I get no > > > spillover with "set term post eps" (without adding "butt") > > > > "Butt" is the default for the PostScript terminals. > > Ah, OK. But then shouldn't that be consistent across terminals? That's one side of the argument. The other side is that "butt" in libgd produces really ugly lines unless they are parallel to x or y. Better to default to the option that isn't so ugly. To be fair, I haven't checked to see if libgd version 2.0.36 is better than earlier versions in this regard. Perhaps they've fixed it. IMHO "rounded" is almost always better visually. The only exception is when you really do need bars that terminate exactly at some given coordinate. |