# Small glitch with EdgeForm and PlotRange

I'm experiencing a small problem with the edges of a square, if the PlotRange has the same size as the square :

aSquare = Graphics[{
EdgeForm[Directive[Thick, Black]], GrayLevel[0.5], Opacity[0.1],
Polygon[{{0, -Pi/2}, {Pi, -Pi/2}, {Pi, Pi/2}, {0, Pi/2}}]
}];

Show[
{aSquare},
PlotRange -> {{0, Pi}, {-Pi/2, Pi/2}},
PlotRangeClipping -> True,
Frame -> None,
Axes -> True,
AxesOrigin -> {Pi/2, 0},
AxesStyle -> GrayLevel[0.75]
]


This code will show the square with two sides having their thickness cut-off in part. All four sides should have exactly the same thickness.

I can solve the issue if I use PlotRange -> {{0 - 0.01, Pi + 0.01}, {-Pi/2 - 0.01, Pi/2 + 0.01}} instead, but this feels like an "hack", and don't seems to be very natural.

What should be the best way of showing that square with its thick borders, while still using the same size for PlotRange ? Take note that I need to keep PlotRangeClipping -> True to cut off some curves that goes outside the square.

• Use PlotRange -> All in Show? – kglr Apr 24 '16 at 18:22
• I'm not sure this will work, once I add all the curves. Those curves need to be shown inside the square only (thus the PlotRangeClipping -> True option). – Cham Apr 24 '16 at 18:24
• Perhaps add a very small amount of padding to the plot range (e.g. PlotRangePadding -> 0.01)? Depending on how your curves are defined, which you don't specify, you might be able to use a RegionFunction to have them plotted only within the square. – MarcoB Apr 24 '16 at 21:51

I think it may be more expedient to use Framed to generate the frame you want, rather than having an extra graphics object:

Framed[
Show[
{
Graphics[{Red, Thick, Circle[]}],
Plot[Sin[x], {x, -2, 5}, PlotStyle -> Directive[Thick, Blue]]
},
PlotRange -> {{0, Pi}, {-Pi/2, Pi/2}},
(*REMOVED*)
(*PlotRangeClipping -> True,*)
(**)
Frame -> None, Axes -> True,
AxesOrigin -> {Pi/2, 0}, AxesStyle -> GrayLevel[0.75],

• I don't know why, but I don't get a thick frame. Removing Thickdoesn't make any difference. (what the ...?) – Cham Apr 25 '16 at 14:19
• @Cham Could you try replacing Thick with an appropriate AbsoluteThickness directive? I tried AbsoluteThickness[3] in the FrameStyle and it looks OK, but you might want to try something outrageous, e.g. 10 or so, to see if it is even doing anything. I'm on 10.4.0; you are on a somewhat older version of MMA if I remember correctly, is that right? – MarcoB Apr 25 '16 at 14:29
• @Cham Also, does the Circle show up as a thick line? That's also using Thick, so I wonder why it would work somewhere but not everywhere! – MarcoB Apr 25 '16 at 14:30