plotting - Is it possible to induce Mathematica to chop off parts of Graphics objects that exist outside of a Frame?
I am running Mathematica 7. In a Graphics environment I am setting Frame -> True (and using FrameLabel -> {"x", "y"} and PlotLabel -> "My Title", etc) so that I can see length scales in Graphics environments.
Suppose that I create a Disk of radius 0.9, centered at the origin. I have set PlotRange -> {{-1, 1}, {-1, 1}}. The result looks nice:
Graphics[{
Cyan, Disk[{0, 0}, 0.9]
},
PlotRange -> {{-1, 1}, {-1, 1}}, Frame -> True,
FrameLabel -> {"x", "y"}, PlotLabel -> "My Disk"]
Now, however, suppose that I want to create a Disk that is not entirely contained in Frame. For example, I might leave PlotRange -> {{-1, 1}, {-1, 1}} and increase the Disk radius from 0.9 to 1.2. However, in the resulting image, the Disk goes beyond the boundaries of the Frame:
Graphics[{
Cyan, Disk[{0, 0}, 1.2]
},
PlotRange -> {{-1, 1}, {-1, 1}}, Frame -> True,
FrameLabel -> {"x", "y"}, PlotLabel -> "My Disk"]
Is there any way that I can direct Mathematica to chop off parts of the Graphics objects that exist outside of the Frame? Thanks for your time.
Answer
If I have understood correctly then PlotRangeClipping -> True is what you need:
Graphics[{Cyan, Disk[{0, 0}, 1.2]}, PlotRange -> {{-1, 1}, {-1, 1}},
Frame -> True, FrameLabel -> {"x", "y"}, PlotLabel -> "My Disk",
PlotRangeClipping -> True]



Comments
Post a Comment