# How to crop graphics outside PlotRange with Show? [duplicate]

Is there an option or method to prevent Graphics from being displayed outside the PlotRange region?

The problem is illustrated below: the gray lines are linear regressors and are being combined using Show with additional graphics.

The spill-over occurs both with and without PlotLabel set and only on the Top portion of the frame. But as I explain below it is more noticeable with PlotLabel set.

The same PlotRange -> {{0, 15}, {0, 175}} is set twice, once in the main scatterplot that renders the frame (it is built up with Graphics elements rather than a ListPlot), and also in the call to Show which combines the scatterplot, highlighted points and the regressors.

But I've also tried removing PlotRange independently in either, with no change in results.

Removing PlotLabel causes the out-of-bounds portion of the lines to be considerably shortened but still visibly outside the boxes.

-

## marked as duplicate by Michael E2, Sjoerd C. de Vries, Artes, m_goldberg, Ｊ. Ｍ.May 16 '13 at 4:33

–  andre May 15 '13 at 19:41

You must add the option PlotRangeClipping -> True

Show[...,PlotRangeClipping -> True]


• Show[gr1,gr2 ...] take the options of the first graphic in the list, gr1 here.
• Concerning the scatterplot, Graphics[] has by default PlotRangeClipping -> False
• Concerning the line, Plot[] has by default PlotRangeClipping -> True
So if gr1 is the Graphic with the scatterplot, the behavior you see is fully explained.