Clip GridLines outside of a circleGraphics plot of point using unfilled circleHow to insert guide-lines in graphics without specifying range?Opacity and overlapping multiple polygonsOne ChartLegend for multiple charts in Dataset?Random non-overlapping disks in a squareIntersecting RegionPlotsHow to implement reusable graphic components having stable line thicknesses?Magnify Part of a 3D GraphicAdding a second color bar to a plotHow to bring 3d effect with transparent sphere?
How to have a sharp product image?
How to write a column outside the braces in a matrix?
What happened to Captain America in Endgame?
Rivers without rain
What are the steps to solving this definite integral?
Elements other than carbon that can form many different compounds by bonding to themselves?
Is there any official lore on the Far Realm?
Alignment of various blocks in tikz
Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?
Does a large simulator bay have standard public address announcements?
How to prevent z-fighting in OpenSCAD?
Why does nature favour the Laplacian?
How to display Aura JS Errors Lightning Out
What is the smallest unit of eos?
What does ゆーか mean?
Apply MapThread to all but one variable
How can I practically buy stocks?
How to denote matrix elements succinctly?
What happens to Mjolnir (Thor's hammer) at the end of Endgame?
Are there physical dangers to preparing a prepared piano?
Was there a shared-world project before "Thieves World"?
I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?
What is the most expensive material in the world that could be used to create Pun-Pun's lute?
First time hit, with spinach? A little bit?
Clip GridLines outside of a circle
Graphics plot of point using unfilled circleHow to insert guide-lines in graphics without specifying range?Opacity and overlapping multiple polygonsOne ChartLegend for multiple charts in Dataset?Random non-overlapping disks in a squareIntersecting RegionPlotsHow to implement reusable graphic components having stable line thicknesses?Magnify Part of a 3D GraphicAdding a second color bar to a plotHow to bring 3d effect with transparent sphere?
$begingroup$
Graphics[Circle[], Frame -> True, GridLines -> Automatic]
This puts grids across a 2D graphic (a circle here).
Is there any way to specify the range of values of GridLines? More specifically I want the part of GridLines that are inside the circle. That is the part of them that is outside the circle should be removed.
Thanks a lot!
graphics grid-lines
$endgroup$
add a comment |
$begingroup$
Graphics[Circle[], Frame -> True, GridLines -> Automatic]
This puts grids across a 2D graphic (a circle here).
Is there any way to specify the range of values of GridLines? More specifically I want the part of GridLines that are inside the circle. That is the part of them that is outside the circle should be removed.
Thanks a lot!
graphics grid-lines
$endgroup$
add a comment |
$begingroup$
Graphics[Circle[], Frame -> True, GridLines -> Automatic]
This puts grids across a 2D graphic (a circle here).
Is there any way to specify the range of values of GridLines? More specifically I want the part of GridLines that are inside the circle. That is the part of them that is outside the circle should be removed.
Thanks a lot!
graphics grid-lines
$endgroup$
Graphics[Circle[], Frame -> True, GridLines -> Automatic]
This puts grids across a 2D graphic (a circle here).
Is there any way to specify the range of values of GridLines? More specifically I want the part of GridLines that are inside the circle. That is the part of them that is outside the circle should be removed.
Thanks a lot!
graphics grid-lines
graphics grid-lines
edited 2 days ago
Carl Woll
75.9k3100198
75.9k3100198
asked Apr 23 at 14:52
DimitrisDimitris
2,3401332
2,3401332
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
You can use a FilledCurve to create a graphics primitive with a hole in it. For example:
Graphics[
White,
FilledCurve[
Line[Scaled[0,0],Scaled[1,0],Scaled[1,1],Scaled[0,1],Scaled[0,0]],
Line@CirclePoints[.5, 100]
],
Blue,
Circle[0,0,.5]
,
Frame -> True,
GridLines -> Automatic
]

Update
My previous answer let the grid lines from the underlying Graphics option show through the hole in the FilledCurve. If you want the grid lines to be rotated, then another approach using Texture and FilledCurve would work better. FilledCurve supports Line, BezierCurve and BSplineCurve segments. The documentation provides an example for creating a circle from a BSplineCurve, so I will use that:
bSplineCircle[c_, r_] := Module[pts=TranslationTransform[c][r $CirclePoints],
BSplineCurve[
pts,
SplineDegree->2,
SplineKnots->$CircleKnots,
SplineWeights->$CircleWeights
]
]
$CircleKnots = 0, 0, 0, 1/4, 1/2, 1/2, 3/4, 1, 1, 1;
$CircleWeights = 1, .5, .5, 1, .5, .5, 1;
$CirclePoints = 0,-1,1,-1,1,1,0,1,-1,1,-1,-1,0,-1;
$CircleTextureCoordinates = .5,0,1,0,1,1,.5,1,0,1,0,0,.5,0;
Example:
Graphics[bSplineCircle[-1,1,1], bSplineCircle[1,-1,.5], Axes->True]

Using the above bSplineCircle function we can create a texturedCircle function:
texturedCircle[c_, r_, texture_, rot_:0] :=
Texture[texture],
FilledCurve[
bSplineCircle[c, r],
VertexTextureCoordinates -> RotationTransform[rot, .5, .5] @ $CircleTextureCoordinates
]
Here is an example using texturedCircle:
Graphics[
EdgeForm[Blue],
texturedCircle[1, 2, 1, Graphics[, GridLines->Automatic], Pi/8],
EdgeForm[Green],
texturedCircle[3, 4, .5, Graphics[, GridLines->Automatic]],
EdgeForm[None],
texturedCircle[3, 1, 1, ExampleData["TestImage","Lena"], Pi/4]
,
Axes->True
]

$endgroup$
$begingroup$
This is perfect! Thank you very much. Is is possible also to modify the orientation of these grid lines (for instance by π/4 rad)?
$endgroup$
– Dimitris
Apr 23 at 16:30
add a comment |
$begingroup$
You may also use parametric plot which can give more flexibility (like the pi/4 rotation you want):
pt = Table[
ParametricPlot[x, x + a, x, 1/2 (-a - Sqrt[2 - a^2]),
1/2 (-a + Sqrt[2 - a^2])], a, -1, 1, .5],
Table[ParametricPlot[x, -x + a, x, 1/2 (a - Sqrt[2 - a^2]),
1/2 (a + Sqrt[2 - a^2])], a, -1, 1, .5] // Flatten;
Show[pt, Graphics[Circle[]], PlotRange -> All, Frame -> True]

where the x range for the gridlines are from
Solve[x + a == Sqrt[1 - x^2], x]
Solve[-x + a == Sqrt[1 - x^2], x]
$endgroup$
$begingroup$
Thanks! How can we modify the code in order to have the center of circle (and the grids translated) to (0.5,0.5)?
$endgroup$
– Dimitris
Apr 23 at 19:52
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f195844%2fclip-gridlines-outside-of-a-circle%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
You can use a FilledCurve to create a graphics primitive with a hole in it. For example:
Graphics[
White,
FilledCurve[
Line[Scaled[0,0],Scaled[1,0],Scaled[1,1],Scaled[0,1],Scaled[0,0]],
Line@CirclePoints[.5, 100]
],
Blue,
Circle[0,0,.5]
,
Frame -> True,
GridLines -> Automatic
]

Update
My previous answer let the grid lines from the underlying Graphics option show through the hole in the FilledCurve. If you want the grid lines to be rotated, then another approach using Texture and FilledCurve would work better. FilledCurve supports Line, BezierCurve and BSplineCurve segments. The documentation provides an example for creating a circle from a BSplineCurve, so I will use that:
bSplineCircle[c_, r_] := Module[pts=TranslationTransform[c][r $CirclePoints],
BSplineCurve[
pts,
SplineDegree->2,
SplineKnots->$CircleKnots,
SplineWeights->$CircleWeights
]
]
$CircleKnots = 0, 0, 0, 1/4, 1/2, 1/2, 3/4, 1, 1, 1;
$CircleWeights = 1, .5, .5, 1, .5, .5, 1;
$CirclePoints = 0,-1,1,-1,1,1,0,1,-1,1,-1,-1,0,-1;
$CircleTextureCoordinates = .5,0,1,0,1,1,.5,1,0,1,0,0,.5,0;
Example:
Graphics[bSplineCircle[-1,1,1], bSplineCircle[1,-1,.5], Axes->True]

Using the above bSplineCircle function we can create a texturedCircle function:
texturedCircle[c_, r_, texture_, rot_:0] :=
Texture[texture],
FilledCurve[
bSplineCircle[c, r],
VertexTextureCoordinates -> RotationTransform[rot, .5, .5] @ $CircleTextureCoordinates
]
Here is an example using texturedCircle:
Graphics[
EdgeForm[Blue],
texturedCircle[1, 2, 1, Graphics[, GridLines->Automatic], Pi/8],
EdgeForm[Green],
texturedCircle[3, 4, .5, Graphics[, GridLines->Automatic]],
EdgeForm[None],
texturedCircle[3, 1, 1, ExampleData["TestImage","Lena"], Pi/4]
,
Axes->True
]

$endgroup$
$begingroup$
This is perfect! Thank you very much. Is is possible also to modify the orientation of these grid lines (for instance by π/4 rad)?
$endgroup$
– Dimitris
Apr 23 at 16:30
add a comment |
$begingroup$
You can use a FilledCurve to create a graphics primitive with a hole in it. For example:
Graphics[
White,
FilledCurve[
Line[Scaled[0,0],Scaled[1,0],Scaled[1,1],Scaled[0,1],Scaled[0,0]],
Line@CirclePoints[.5, 100]
],
Blue,
Circle[0,0,.5]
,
Frame -> True,
GridLines -> Automatic
]

Update
My previous answer let the grid lines from the underlying Graphics option show through the hole in the FilledCurve. If you want the grid lines to be rotated, then another approach using Texture and FilledCurve would work better. FilledCurve supports Line, BezierCurve and BSplineCurve segments. The documentation provides an example for creating a circle from a BSplineCurve, so I will use that:
bSplineCircle[c_, r_] := Module[pts=TranslationTransform[c][r $CirclePoints],
BSplineCurve[
pts,
SplineDegree->2,
SplineKnots->$CircleKnots,
SplineWeights->$CircleWeights
]
]
$CircleKnots = 0, 0, 0, 1/4, 1/2, 1/2, 3/4, 1, 1, 1;
$CircleWeights = 1, .5, .5, 1, .5, .5, 1;
$CirclePoints = 0,-1,1,-1,1,1,0,1,-1,1,-1,-1,0,-1;
$CircleTextureCoordinates = .5,0,1,0,1,1,.5,1,0,1,0,0,.5,0;
Example:
Graphics[bSplineCircle[-1,1,1], bSplineCircle[1,-1,.5], Axes->True]

Using the above bSplineCircle function we can create a texturedCircle function:
texturedCircle[c_, r_, texture_, rot_:0] :=
Texture[texture],
FilledCurve[
bSplineCircle[c, r],
VertexTextureCoordinates -> RotationTransform[rot, .5, .5] @ $CircleTextureCoordinates
]
Here is an example using texturedCircle:
Graphics[
EdgeForm[Blue],
texturedCircle[1, 2, 1, Graphics[, GridLines->Automatic], Pi/8],
EdgeForm[Green],
texturedCircle[3, 4, .5, Graphics[, GridLines->Automatic]],
EdgeForm[None],
texturedCircle[3, 1, 1, ExampleData["TestImage","Lena"], Pi/4]
,
Axes->True
]

$endgroup$
$begingroup$
This is perfect! Thank you very much. Is is possible also to modify the orientation of these grid lines (for instance by π/4 rad)?
$endgroup$
– Dimitris
Apr 23 at 16:30
add a comment |
$begingroup$
You can use a FilledCurve to create a graphics primitive with a hole in it. For example:
Graphics[
White,
FilledCurve[
Line[Scaled[0,0],Scaled[1,0],Scaled[1,1],Scaled[0,1],Scaled[0,0]],
Line@CirclePoints[.5, 100]
],
Blue,
Circle[0,0,.5]
,
Frame -> True,
GridLines -> Automatic
]

Update
My previous answer let the grid lines from the underlying Graphics option show through the hole in the FilledCurve. If you want the grid lines to be rotated, then another approach using Texture and FilledCurve would work better. FilledCurve supports Line, BezierCurve and BSplineCurve segments. The documentation provides an example for creating a circle from a BSplineCurve, so I will use that:
bSplineCircle[c_, r_] := Module[pts=TranslationTransform[c][r $CirclePoints],
BSplineCurve[
pts,
SplineDegree->2,
SplineKnots->$CircleKnots,
SplineWeights->$CircleWeights
]
]
$CircleKnots = 0, 0, 0, 1/4, 1/2, 1/2, 3/4, 1, 1, 1;
$CircleWeights = 1, .5, .5, 1, .5, .5, 1;
$CirclePoints = 0,-1,1,-1,1,1,0,1,-1,1,-1,-1,0,-1;
$CircleTextureCoordinates = .5,0,1,0,1,1,.5,1,0,1,0,0,.5,0;
Example:
Graphics[bSplineCircle[-1,1,1], bSplineCircle[1,-1,.5], Axes->True]

Using the above bSplineCircle function we can create a texturedCircle function:
texturedCircle[c_, r_, texture_, rot_:0] :=
Texture[texture],
FilledCurve[
bSplineCircle[c, r],
VertexTextureCoordinates -> RotationTransform[rot, .5, .5] @ $CircleTextureCoordinates
]
Here is an example using texturedCircle:
Graphics[
EdgeForm[Blue],
texturedCircle[1, 2, 1, Graphics[, GridLines->Automatic], Pi/8],
EdgeForm[Green],
texturedCircle[3, 4, .5, Graphics[, GridLines->Automatic]],
EdgeForm[None],
texturedCircle[3, 1, 1, ExampleData["TestImage","Lena"], Pi/4]
,
Axes->True
]

$endgroup$
You can use a FilledCurve to create a graphics primitive with a hole in it. For example:
Graphics[
White,
FilledCurve[
Line[Scaled[0,0],Scaled[1,0],Scaled[1,1],Scaled[0,1],Scaled[0,0]],
Line@CirclePoints[.5, 100]
],
Blue,
Circle[0,0,.5]
,
Frame -> True,
GridLines -> Automatic
]

Update
My previous answer let the grid lines from the underlying Graphics option show through the hole in the FilledCurve. If you want the grid lines to be rotated, then another approach using Texture and FilledCurve would work better. FilledCurve supports Line, BezierCurve and BSplineCurve segments. The documentation provides an example for creating a circle from a BSplineCurve, so I will use that:
bSplineCircle[c_, r_] := Module[pts=TranslationTransform[c][r $CirclePoints],
BSplineCurve[
pts,
SplineDegree->2,
SplineKnots->$CircleKnots,
SplineWeights->$CircleWeights
]
]
$CircleKnots = 0, 0, 0, 1/4, 1/2, 1/2, 3/4, 1, 1, 1;
$CircleWeights = 1, .5, .5, 1, .5, .5, 1;
$CirclePoints = 0,-1,1,-1,1,1,0,1,-1,1,-1,-1,0,-1;
$CircleTextureCoordinates = .5,0,1,0,1,1,.5,1,0,1,0,0,.5,0;
Example:
Graphics[bSplineCircle[-1,1,1], bSplineCircle[1,-1,.5], Axes->True]

Using the above bSplineCircle function we can create a texturedCircle function:
texturedCircle[c_, r_, texture_, rot_:0] :=
Texture[texture],
FilledCurve[
bSplineCircle[c, r],
VertexTextureCoordinates -> RotationTransform[rot, .5, .5] @ $CircleTextureCoordinates
]
Here is an example using texturedCircle:
Graphics[
EdgeForm[Blue],
texturedCircle[1, 2, 1, Graphics[, GridLines->Automatic], Pi/8],
EdgeForm[Green],
texturedCircle[3, 4, .5, Graphics[, GridLines->Automatic]],
EdgeForm[None],
texturedCircle[3, 1, 1, ExampleData["TestImage","Lena"], Pi/4]
,
Axes->True
]

edited 2 days ago
answered Apr 23 at 15:57
Carl WollCarl Woll
75.9k3100198
75.9k3100198
$begingroup$
This is perfect! Thank you very much. Is is possible also to modify the orientation of these grid lines (for instance by π/4 rad)?
$endgroup$
– Dimitris
Apr 23 at 16:30
add a comment |
$begingroup$
This is perfect! Thank you very much. Is is possible also to modify the orientation of these grid lines (for instance by π/4 rad)?
$endgroup$
– Dimitris
Apr 23 at 16:30
$begingroup$
This is perfect! Thank you very much. Is is possible also to modify the orientation of these grid lines (for instance by π/4 rad)?
$endgroup$
– Dimitris
Apr 23 at 16:30
$begingroup$
This is perfect! Thank you very much. Is is possible also to modify the orientation of these grid lines (for instance by π/4 rad)?
$endgroup$
– Dimitris
Apr 23 at 16:30
add a comment |
$begingroup$
You may also use parametric plot which can give more flexibility (like the pi/4 rotation you want):
pt = Table[
ParametricPlot[x, x + a, x, 1/2 (-a - Sqrt[2 - a^2]),
1/2 (-a + Sqrt[2 - a^2])], a, -1, 1, .5],
Table[ParametricPlot[x, -x + a, x, 1/2 (a - Sqrt[2 - a^2]),
1/2 (a + Sqrt[2 - a^2])], a, -1, 1, .5] // Flatten;
Show[pt, Graphics[Circle[]], PlotRange -> All, Frame -> True]

where the x range for the gridlines are from
Solve[x + a == Sqrt[1 - x^2], x]
Solve[-x + a == Sqrt[1 - x^2], x]
$endgroup$
$begingroup$
Thanks! How can we modify the code in order to have the center of circle (and the grids translated) to (0.5,0.5)?
$endgroup$
– Dimitris
Apr 23 at 19:52
add a comment |
$begingroup$
You may also use parametric plot which can give more flexibility (like the pi/4 rotation you want):
pt = Table[
ParametricPlot[x, x + a, x, 1/2 (-a - Sqrt[2 - a^2]),
1/2 (-a + Sqrt[2 - a^2])], a, -1, 1, .5],
Table[ParametricPlot[x, -x + a, x, 1/2 (a - Sqrt[2 - a^2]),
1/2 (a + Sqrt[2 - a^2])], a, -1, 1, .5] // Flatten;
Show[pt, Graphics[Circle[]], PlotRange -> All, Frame -> True]

where the x range for the gridlines are from
Solve[x + a == Sqrt[1 - x^2], x]
Solve[-x + a == Sqrt[1 - x^2], x]
$endgroup$
$begingroup$
Thanks! How can we modify the code in order to have the center of circle (and the grids translated) to (0.5,0.5)?
$endgroup$
– Dimitris
Apr 23 at 19:52
add a comment |
$begingroup$
You may also use parametric plot which can give more flexibility (like the pi/4 rotation you want):
pt = Table[
ParametricPlot[x, x + a, x, 1/2 (-a - Sqrt[2 - a^2]),
1/2 (-a + Sqrt[2 - a^2])], a, -1, 1, .5],
Table[ParametricPlot[x, -x + a, x, 1/2 (a - Sqrt[2 - a^2]),
1/2 (a + Sqrt[2 - a^2])], a, -1, 1, .5] // Flatten;
Show[pt, Graphics[Circle[]], PlotRange -> All, Frame -> True]

where the x range for the gridlines are from
Solve[x + a == Sqrt[1 - x^2], x]
Solve[-x + a == Sqrt[1 - x^2], x]
$endgroup$
You may also use parametric plot which can give more flexibility (like the pi/4 rotation you want):
pt = Table[
ParametricPlot[x, x + a, x, 1/2 (-a - Sqrt[2 - a^2]),
1/2 (-a + Sqrt[2 - a^2])], a, -1, 1, .5],
Table[ParametricPlot[x, -x + a, x, 1/2 (a - Sqrt[2 - a^2]),
1/2 (a + Sqrt[2 - a^2])], a, -1, 1, .5] // Flatten;
Show[pt, Graphics[Circle[]], PlotRange -> All, Frame -> True]

where the x range for the gridlines are from
Solve[x + a == Sqrt[1 - x^2], x]
Solve[-x + a == Sqrt[1 - x^2], x]
answered Apr 23 at 17:44
egwene sedaiegwene sedai
1,8361021
1,8361021
$begingroup$
Thanks! How can we modify the code in order to have the center of circle (and the grids translated) to (0.5,0.5)?
$endgroup$
– Dimitris
Apr 23 at 19:52
add a comment |
$begingroup$
Thanks! How can we modify the code in order to have the center of circle (and the grids translated) to (0.5,0.5)?
$endgroup$
– Dimitris
Apr 23 at 19:52
$begingroup$
Thanks! How can we modify the code in order to have the center of circle (and the grids translated) to (0.5,0.5)?
$endgroup$
– Dimitris
Apr 23 at 19:52
$begingroup$
Thanks! How can we modify the code in order to have the center of circle (and the grids translated) to (0.5,0.5)?
$endgroup$
– Dimitris
Apr 23 at 19:52
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f195844%2fclip-gridlines-outside-of-a-circle%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown