Re: Problem/bug with ends of thick lines in graphics
- To: mathgroup at smc.vnet.net
- Subject: [mg88443] Re: Problem/bug with ends of thick lines in graphics
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Mon, 5 May 2008 06:15:43 -0400 (EDT)
- References: <fvhe27$3t8$1@smc.vnet.net>
Hi, Plot[x, {x, 1/3, 3/4}, PlotRange -> {{0, 1}, {0, 1}}, PlotStyle -> {AbsoluteThickness[20]}] /. Line[pnts_] :> {AbsolutePointSize[20], Point[pnts]} may help in this case. But AFAIK Mathematica has no directive to set the line ends. Regards Jens David Reiss wrote: > In a quick search of things I haven't found a mention of the following > simple graphics issue and I'm checking in with the group to see if > there is a memory of its mention and if there is a simple fix (and > which is not a complicated hack) that I've not been able to come up > with. > > Consider the following graph: > > Plot[x, {x, 1/3, 3/4}, PlotRange -> {{0, 1}, {0, 1}}, > PlotStyle -> {AbsoluteThickness[20]}] > > When you plot it you will see that the line's ends are not > rectangular, whereas you would certainly want them to be so. (An > alternative would be to have them be rounded, for example, but the > question will remain the same whatever your preference is.) Rather > they appear as polygonal in a way inconsistent with the line itself. > > One assums that this is an artifact of how the line is rendered based > on the individual line segments, and that that segmental rendering has > to do something with how a segment relates to the segments on either > side of it. The lack of a segment beyond the end segment presumably > runes the algorithm for rendering in a way that leads to this > appearance. > > I have two related questions here. The first is how, if at all > possible, to fix this in a general way through some specific options > settings for the graphics function. > > The second is how, when exporting this graphic as, say, a PDF, to make > it behave properly. > > There was a trick in pre version-6 Mathematica that would involve > adding an explicit postscript command to the PlotStyle option. Though > this would not (I think) correct the screen appearance of the graphic, > it would properly fix it when the graphic was exported to PDF or EPS. > Here is an example of how it was done: > > Plot[x, {x, 1/3, 3/4}, PlotRange -> {{0, 1}, {0, 1}}, > PlotStyle -> {{ PostScript["0 setlinecap"],AbsoluteThickness[20]}}] > > This, however, no longer works in Mathematica 6+ presumably because of > the new way that graphics rendering is handled. > > Does anyone have any solutions to either or both of these issues? > > Thanks! > > --David >