Specific part of background in a plot - outside plotting area











up vote
3
down vote

favorite












I need to add a rectangle to my plot that includes being behind the ticks but not the label of my graph.



I know with Prologyou can add a rectangle, like with the code:



Plot[x^2, {x, 0, 3}, Prolog -> {Red, Rectangle[Scaled[{0., 0.8}], Scaled[{1, 1}]]}, Frame -> True, FrameLabel -> {"x", "y"}]


enter image description here



But I need the rectangle to go beyond where it is now, to be wider, and actually be behind the number 8 (but not behind the frame label) and go passed the frame a little bit on other side too. With Background I could cover the whole thing but I am only interested in that rectangle and need the rest of the picture to remain backgroundless.



Is it at all posible?
Thank you!










share|improve this question






















  • Interestingly, I just got here and had a look at the images. I first saw the images in the two answers and thought, "ugh, this looks ugly with the rectangle extending outside the box". Then I saw the nice image in your question. And finally I was surprised to learn that you actually asked for the style in the answers!
    – Andreas Rejbrand
    4 hours ago










  • Yes. The graph I am trying to make is obviously way more complicated than that but that's what I was looking for. It serves to hightlight other graphics that will be displayed along side this one.
    – M.O.
    1 hour ago















up vote
3
down vote

favorite












I need to add a rectangle to my plot that includes being behind the ticks but not the label of my graph.



I know with Prologyou can add a rectangle, like with the code:



Plot[x^2, {x, 0, 3}, Prolog -> {Red, Rectangle[Scaled[{0., 0.8}], Scaled[{1, 1}]]}, Frame -> True, FrameLabel -> {"x", "y"}]


enter image description here



But I need the rectangle to go beyond where it is now, to be wider, and actually be behind the number 8 (but not behind the frame label) and go passed the frame a little bit on other side too. With Background I could cover the whole thing but I am only interested in that rectangle and need the rest of the picture to remain backgroundless.



Is it at all posible?
Thank you!










share|improve this question






















  • Interestingly, I just got here and had a look at the images. I first saw the images in the two answers and thought, "ugh, this looks ugly with the rectangle extending outside the box". Then I saw the nice image in your question. And finally I was surprised to learn that you actually asked for the style in the answers!
    – Andreas Rejbrand
    4 hours ago










  • Yes. The graph I am trying to make is obviously way more complicated than that but that's what I was looking for. It serves to hightlight other graphics that will be displayed along side this one.
    – M.O.
    1 hour ago













up vote
3
down vote

favorite









up vote
3
down vote

favorite











I need to add a rectangle to my plot that includes being behind the ticks but not the label of my graph.



I know with Prologyou can add a rectangle, like with the code:



Plot[x^2, {x, 0, 3}, Prolog -> {Red, Rectangle[Scaled[{0., 0.8}], Scaled[{1, 1}]]}, Frame -> True, FrameLabel -> {"x", "y"}]


enter image description here



But I need the rectangle to go beyond where it is now, to be wider, and actually be behind the number 8 (but not behind the frame label) and go passed the frame a little bit on other side too. With Background I could cover the whole thing but I am only interested in that rectangle and need the rest of the picture to remain backgroundless.



Is it at all posible?
Thank you!










share|improve this question













I need to add a rectangle to my plot that includes being behind the ticks but not the label of my graph.



I know with Prologyou can add a rectangle, like with the code:



Plot[x^2, {x, 0, 3}, Prolog -> {Red, Rectangle[Scaled[{0., 0.8}], Scaled[{1, 1}]]}, Frame -> True, FrameLabel -> {"x", "y"}]


enter image description here



But I need the rectangle to go beyond where it is now, to be wider, and actually be behind the number 8 (but not behind the frame label) and go passed the frame a little bit on other side too. With Background I could cover the whole thing but I am only interested in that rectangle and need the rest of the picture to remain backgroundless.



Is it at all posible?
Thank you!







plotting






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 11 hours ago









M.O.

967




967












  • Interestingly, I just got here and had a look at the images. I first saw the images in the two answers and thought, "ugh, this looks ugly with the rectangle extending outside the box". Then I saw the nice image in your question. And finally I was surprised to learn that you actually asked for the style in the answers!
    – Andreas Rejbrand
    4 hours ago










  • Yes. The graph I am trying to make is obviously way more complicated than that but that's what I was looking for. It serves to hightlight other graphics that will be displayed along side this one.
    – M.O.
    1 hour ago


















  • Interestingly, I just got here and had a look at the images. I first saw the images in the two answers and thought, "ugh, this looks ugly with the rectangle extending outside the box". Then I saw the nice image in your question. And finally I was surprised to learn that you actually asked for the style in the answers!
    – Andreas Rejbrand
    4 hours ago










  • Yes. The graph I am trying to make is obviously way more complicated than that but that's what I was looking for. It serves to hightlight other graphics that will be displayed along side this one.
    – M.O.
    1 hour ago
















Interestingly, I just got here and had a look at the images. I first saw the images in the two answers and thought, "ugh, this looks ugly with the rectangle extending outside the box". Then I saw the nice image in your question. And finally I was surprised to learn that you actually asked for the style in the answers!
– Andreas Rejbrand
4 hours ago




Interestingly, I just got here and had a look at the images. I first saw the images in the two answers and thought, "ugh, this looks ugly with the rectangle extending outside the box". Then I saw the nice image in your question. And finally I was surprised to learn that you actually asked for the style in the answers!
– Andreas Rejbrand
4 hours ago












Yes. The graph I am trying to make is obviously way more complicated than that but that's what I was looking for. It serves to hightlight other graphics that will be displayed along side this one.
– M.O.
1 hour ago




Yes. The graph I am trying to make is obviously way more complicated than that but that's what I was looking for. It serves to hightlight other graphics that will be displayed along side this one.
– M.O.
1 hour ago










2 Answers
2






active

oldest

votes

















up vote
6
down vote



accepted










You can use PlotRangeClipping->False and extend the Rectangle:



Plot[x^2, {x, 0, 3},
Prolog -> {Red, Rectangle[Scaled[{-.03,.8}],Scaled[{1.03,1}]]},
Frame -> True,
FrameLabel -> {"x","y"},
PlotRangeClipping -> False
]


enter image description here






share|improve this answer





















  • Thank you! I had tried negative values of Scaled but it didnt do anything!
    – M.O.
    10 hours ago










  • My plot is a ListLinePlot of imported data. The data beyond the range is showing becuase the plotting area hasnt been clipped. Is there any way to hide it that you know of?
    – M.O.
    10 hours ago


















up vote
3
down vote













Here is alternative way to do it.



Show[Graphics[{Red, Rectangle[{-0.1, 7.8}, {3, 9}]}, 
PlotRange -> {{0, 3}, {0, 9}}, AspectRatio -> 1/GoldenRatio,
Frame -> True, FrameLabel -> {"x", "y"}], Plot[x^2, {x, 0, 3}]]


enter image description here






share|improve this answer





















  • Very simple! Thanks!
    – M.O.
    9 hours ago











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

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',
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f187912%2fspecific-part-of-background-in-a-plot-outside-plotting-area%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








up vote
6
down vote



accepted










You can use PlotRangeClipping->False and extend the Rectangle:



Plot[x^2, {x, 0, 3},
Prolog -> {Red, Rectangle[Scaled[{-.03,.8}],Scaled[{1.03,1}]]},
Frame -> True,
FrameLabel -> {"x","y"},
PlotRangeClipping -> False
]


enter image description here






share|improve this answer





















  • Thank you! I had tried negative values of Scaled but it didnt do anything!
    – M.O.
    10 hours ago










  • My plot is a ListLinePlot of imported data. The data beyond the range is showing becuase the plotting area hasnt been clipped. Is there any way to hide it that you know of?
    – M.O.
    10 hours ago















up vote
6
down vote



accepted










You can use PlotRangeClipping->False and extend the Rectangle:



Plot[x^2, {x, 0, 3},
Prolog -> {Red, Rectangle[Scaled[{-.03,.8}],Scaled[{1.03,1}]]},
Frame -> True,
FrameLabel -> {"x","y"},
PlotRangeClipping -> False
]


enter image description here






share|improve this answer





















  • Thank you! I had tried negative values of Scaled but it didnt do anything!
    – M.O.
    10 hours ago










  • My plot is a ListLinePlot of imported data. The data beyond the range is showing becuase the plotting area hasnt been clipped. Is there any way to hide it that you know of?
    – M.O.
    10 hours ago













up vote
6
down vote



accepted







up vote
6
down vote



accepted






You can use PlotRangeClipping->False and extend the Rectangle:



Plot[x^2, {x, 0, 3},
Prolog -> {Red, Rectangle[Scaled[{-.03,.8}],Scaled[{1.03,1}]]},
Frame -> True,
FrameLabel -> {"x","y"},
PlotRangeClipping -> False
]


enter image description here






share|improve this answer












You can use PlotRangeClipping->False and extend the Rectangle:



Plot[x^2, {x, 0, 3},
Prolog -> {Red, Rectangle[Scaled[{-.03,.8}],Scaled[{1.03,1}]]},
Frame -> True,
FrameLabel -> {"x","y"},
PlotRangeClipping -> False
]


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered 11 hours ago









Carl Woll

66.6k385174




66.6k385174












  • Thank you! I had tried negative values of Scaled but it didnt do anything!
    – M.O.
    10 hours ago










  • My plot is a ListLinePlot of imported data. The data beyond the range is showing becuase the plotting area hasnt been clipped. Is there any way to hide it that you know of?
    – M.O.
    10 hours ago


















  • Thank you! I had tried negative values of Scaled but it didnt do anything!
    – M.O.
    10 hours ago










  • My plot is a ListLinePlot of imported data. The data beyond the range is showing becuase the plotting area hasnt been clipped. Is there any way to hide it that you know of?
    – M.O.
    10 hours ago
















Thank you! I had tried negative values of Scaled but it didnt do anything!
– M.O.
10 hours ago




Thank you! I had tried negative values of Scaled but it didnt do anything!
– M.O.
10 hours ago












My plot is a ListLinePlot of imported data. The data beyond the range is showing becuase the plotting area hasnt been clipped. Is there any way to hide it that you know of?
– M.O.
10 hours ago




My plot is a ListLinePlot of imported data. The data beyond the range is showing becuase the plotting area hasnt been clipped. Is there any way to hide it that you know of?
– M.O.
10 hours ago










up vote
3
down vote













Here is alternative way to do it.



Show[Graphics[{Red, Rectangle[{-0.1, 7.8}, {3, 9}]}, 
PlotRange -> {{0, 3}, {0, 9}}, AspectRatio -> 1/GoldenRatio,
Frame -> True, FrameLabel -> {"x", "y"}], Plot[x^2, {x, 0, 3}]]


enter image description here






share|improve this answer





















  • Very simple! Thanks!
    – M.O.
    9 hours ago















up vote
3
down vote













Here is alternative way to do it.



Show[Graphics[{Red, Rectangle[{-0.1, 7.8}, {3, 9}]}, 
PlotRange -> {{0, 3}, {0, 9}}, AspectRatio -> 1/GoldenRatio,
Frame -> True, FrameLabel -> {"x", "y"}], Plot[x^2, {x, 0, 3}]]


enter image description here






share|improve this answer





















  • Very simple! Thanks!
    – M.O.
    9 hours ago













up vote
3
down vote










up vote
3
down vote









Here is alternative way to do it.



Show[Graphics[{Red, Rectangle[{-0.1, 7.8}, {3, 9}]}, 
PlotRange -> {{0, 3}, {0, 9}}, AspectRatio -> 1/GoldenRatio,
Frame -> True, FrameLabel -> {"x", "y"}], Plot[x^2, {x, 0, 3}]]


enter image description here






share|improve this answer












Here is alternative way to do it.



Show[Graphics[{Red, Rectangle[{-0.1, 7.8}, {3, 9}]}, 
PlotRange -> {{0, 3}, {0, 9}}, AspectRatio -> 1/GoldenRatio,
Frame -> True, FrameLabel -> {"x", "y"}], Plot[x^2, {x, 0, 3}]]


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered 10 hours ago









Okkes Dulgerci

3,7751716




3,7751716












  • Very simple! Thanks!
    – M.O.
    9 hours ago


















  • Very simple! Thanks!
    – M.O.
    9 hours ago
















Very simple! Thanks!
– M.O.
9 hours ago




Very simple! Thanks!
– M.O.
9 hours ago


















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f187912%2fspecific-part-of-background-in-a-plot-outside-plotting-area%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei