Shading the region bound by two graphs
How do I shade the region bound by the standard parabola and the square root function?
documentclass{amsart}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{calc,intersections}
usepackage{pgfplots}
pgfplotsset{compat=1.11}
begin{document}
raisebox{0mm}[0mm][0mm]
{
begin{tikzpicture}
begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
axis lines=middle,
xmin=-2,xmax=4, domain=-2:4,
ymin=-0.75,ymax=4,
restrict y to domain=-0.75:4,
xtick={empty},ytick={empty},
axis lines=middle,
axis line style={latex-latex},
xlabel=textit{x},ylabel=textit{y},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
%The graphs of the square root function and the standard parabola are plotted.
addplot[samples=501, domain=-2:2] {x^2};
addplot[samples=501, domain=0:4] {sqrt(x)};
%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
coordinate (A) at (-15/8,225/64);
coordinate (B) at (-15/16,0);
%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
coordinate (P) at (15/4,{sqrt(15/4)});
coordinate (Q) at (0,{1/4*sqrt(15)});
end{axis}
%A "pin" is drawn to A.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0, font=scriptsize]{makebox[0pt][r]{$y=x^{2}$}};
%A "pin" is drawn to P.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
node[anchor=north, inner sep=0, outer sep=0, font=scriptsize] at ($(P)!0.4cm!90:(Q)$){makebox[0pt][l]{$y=sqrt{x}$}};
end{tikzpicture}
}
end{document}
tikz-pgf pgfplots fillbetween
add a comment |
How do I shade the region bound by the standard parabola and the square root function?
documentclass{amsart}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{calc,intersections}
usepackage{pgfplots}
pgfplotsset{compat=1.11}
begin{document}
raisebox{0mm}[0mm][0mm]
{
begin{tikzpicture}
begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
axis lines=middle,
xmin=-2,xmax=4, domain=-2:4,
ymin=-0.75,ymax=4,
restrict y to domain=-0.75:4,
xtick={empty},ytick={empty},
axis lines=middle,
axis line style={latex-latex},
xlabel=textit{x},ylabel=textit{y},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
%The graphs of the square root function and the standard parabola are plotted.
addplot[samples=501, domain=-2:2] {x^2};
addplot[samples=501, domain=0:4] {sqrt(x)};
%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
coordinate (A) at (-15/8,225/64);
coordinate (B) at (-15/16,0);
%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
coordinate (P) at (15/4,{sqrt(15/4)});
coordinate (Q) at (0,{1/4*sqrt(15)});
end{axis}
%A "pin" is drawn to A.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0, font=scriptsize]{makebox[0pt][r]{$y=x^{2}$}};
%A "pin" is drawn to P.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
node[anchor=north, inner sep=0, outer sep=0, font=scriptsize] at ($(P)!0.4cm!90:(Q)$){makebox[0pt][l]{$y=sqrt{x}$}};
end{tikzpicture}
}
end{document}
tikz-pgf pgfplots fillbetween
1
This is the code for a typical plot seen in a Calculus course.
– user143462
Nov 29 at 19:28
add a comment |
How do I shade the region bound by the standard parabola and the square root function?
documentclass{amsart}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{calc,intersections}
usepackage{pgfplots}
pgfplotsset{compat=1.11}
begin{document}
raisebox{0mm}[0mm][0mm]
{
begin{tikzpicture}
begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
axis lines=middle,
xmin=-2,xmax=4, domain=-2:4,
ymin=-0.75,ymax=4,
restrict y to domain=-0.75:4,
xtick={empty},ytick={empty},
axis lines=middle,
axis line style={latex-latex},
xlabel=textit{x},ylabel=textit{y},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
%The graphs of the square root function and the standard parabola are plotted.
addplot[samples=501, domain=-2:2] {x^2};
addplot[samples=501, domain=0:4] {sqrt(x)};
%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
coordinate (A) at (-15/8,225/64);
coordinate (B) at (-15/16,0);
%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
coordinate (P) at (15/4,{sqrt(15/4)});
coordinate (Q) at (0,{1/4*sqrt(15)});
end{axis}
%A "pin" is drawn to A.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0, font=scriptsize]{makebox[0pt][r]{$y=x^{2}$}};
%A "pin" is drawn to P.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
node[anchor=north, inner sep=0, outer sep=0, font=scriptsize] at ($(P)!0.4cm!90:(Q)$){makebox[0pt][l]{$y=sqrt{x}$}};
end{tikzpicture}
}
end{document}
tikz-pgf pgfplots fillbetween
How do I shade the region bound by the standard parabola and the square root function?
documentclass{amsart}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{calc,intersections}
usepackage{pgfplots}
pgfplotsset{compat=1.11}
begin{document}
raisebox{0mm}[0mm][0mm]
{
begin{tikzpicture}
begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
axis lines=middle,
xmin=-2,xmax=4, domain=-2:4,
ymin=-0.75,ymax=4,
restrict y to domain=-0.75:4,
xtick={empty},ytick={empty},
axis lines=middle,
axis line style={latex-latex},
xlabel=textit{x},ylabel=textit{y},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
%The graphs of the square root function and the standard parabola are plotted.
addplot[samples=501, domain=-2:2] {x^2};
addplot[samples=501, domain=0:4] {sqrt(x)};
%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
coordinate (A) at (-15/8,225/64);
coordinate (B) at (-15/16,0);
%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
coordinate (P) at (15/4,{sqrt(15/4)});
coordinate (Q) at (0,{1/4*sqrt(15)});
end{axis}
%A "pin" is drawn to A.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0, font=scriptsize]{makebox[0pt][r]{$y=x^{2}$}};
%A "pin" is drawn to P.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
node[anchor=north, inner sep=0, outer sep=0, font=scriptsize] at ($(P)!0.4cm!90:(Q)$){makebox[0pt][l]{$y=sqrt{x}$}};
end{tikzpicture}
}
end{document}
tikz-pgf pgfplots fillbetween
tikz-pgf pgfplots fillbetween
edited Dec 3 at 7:47
Stefan Pinnow
19.4k83175
19.4k83175
asked Nov 29 at 19:22
Adelyn
1,4381023
1,4381023
1
This is the code for a typical plot seen in a Calculus course.
– user143462
Nov 29 at 19:28
add a comment |
1
This is the code for a typical plot seen in a Calculus course.
– user143462
Nov 29 at 19:28
1
1
This is the code for a typical plot seen in a Calculus course.
– user143462
Nov 29 at 19:28
This is the code for a typical plot seen in a Calculus course.
– user143462
Nov 29 at 19:28
add a comment |
1 Answer
1
active
oldest
votes
That's a standard task for the fillbetween
library.
documentclass{amsart}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{calc}
usepackage{pgfplots}
pgfplotsset{compat=1.11}
usepgfplotslibrary{fillbetween}
begin{document}
raisebox{0mm}[0mm][0mm]
{
begin{tikzpicture}
begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
axis lines=middle,
xmin=-2,xmax=4, domain=-2:4,
ymin=-0.75,ymax=4,
restrict y to domain=-0.75:4,
xtick={empty},ytick={empty},
axis lines=middle,
axis line style={latex-latex},
xlabel=textit{x},ylabel=textit{y},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
%The graphs of the square root function and the standard parabola are plotted.
addplot[samples=501, domain=-2:2,name path=parabola] {x^2};
addplot[samples=501, domain=0:4,name path=root] {sqrt(x)};
addplot[red!10] fill between [of=parabola and root, soft clip={domain=0:1}];
%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
coordinate (A) at (-15/8,225/64);
coordinate (B) at (-15/16,0);
%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
coordinate (P) at (15/4,{sqrt(15/4)});
coordinate (Q) at (0,{1/4*sqrt(15)});
end{axis}
%A "pin" is drawn to A.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0, font=scriptsize]{makebox[0pt][r]{$y=x^{2}$}};
%A "pin" is drawn to P.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
node[anchor=north, inner sep=0, outer sep=0, font=scriptsize] at ($(P)!0.4cm!90:(Q)$){makebox[0pt][l]{$y=sqrt{x}$}};
end{tikzpicture}
}
end{document}
Please see the response that I posted.
– Adelyn
Nov 30 at 0:05
@Adelyn I just looked at your follow-up question. As far as I can see, the shading does appear there. Is that correct? (As far as I can see the main issue is that the dimension of your left minipage is to generous, so you may just reduce6in
to3.5in
unless you want to use other methods such aswrapfig
.)
– marmot
Nov 30 at 1:17
The shading is not there. I replacedred!10
withblack
and nothing happens - the region between the two graphs is not shaded. Do I have to manually download a package onto the hard drive?
– Adelyn
Dec 7 at 17:44
Regarding the follow-up question, I would prefer not to change the margins for anyminipage
environment. What would you suggest for awrapfig
?
– Adelyn
Dec 7 at 17:47
@Adelyn I am sorry, this is the output I am getting on my machine. And I have no idea why it is not there on your machine. And as for your follow-up question, I guess it is better if you place requests there. If you do not accept this answer because it does not give you the desired output, that's perfectly fine. But I cannot really make statements on answers that I did not write.
– marmot
Dec 7 at 19:21
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
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%2ftex.stackexchange.com%2fquestions%2f462448%2fshading-the-region-bound-by-two-graphs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
That's a standard task for the fillbetween
library.
documentclass{amsart}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{calc}
usepackage{pgfplots}
pgfplotsset{compat=1.11}
usepgfplotslibrary{fillbetween}
begin{document}
raisebox{0mm}[0mm][0mm]
{
begin{tikzpicture}
begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
axis lines=middle,
xmin=-2,xmax=4, domain=-2:4,
ymin=-0.75,ymax=4,
restrict y to domain=-0.75:4,
xtick={empty},ytick={empty},
axis lines=middle,
axis line style={latex-latex},
xlabel=textit{x},ylabel=textit{y},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
%The graphs of the square root function and the standard parabola are plotted.
addplot[samples=501, domain=-2:2,name path=parabola] {x^2};
addplot[samples=501, domain=0:4,name path=root] {sqrt(x)};
addplot[red!10] fill between [of=parabola and root, soft clip={domain=0:1}];
%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
coordinate (A) at (-15/8,225/64);
coordinate (B) at (-15/16,0);
%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
coordinate (P) at (15/4,{sqrt(15/4)});
coordinate (Q) at (0,{1/4*sqrt(15)});
end{axis}
%A "pin" is drawn to A.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0, font=scriptsize]{makebox[0pt][r]{$y=x^{2}$}};
%A "pin" is drawn to P.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
node[anchor=north, inner sep=0, outer sep=0, font=scriptsize] at ($(P)!0.4cm!90:(Q)$){makebox[0pt][l]{$y=sqrt{x}$}};
end{tikzpicture}
}
end{document}
Please see the response that I posted.
– Adelyn
Nov 30 at 0:05
@Adelyn I just looked at your follow-up question. As far as I can see, the shading does appear there. Is that correct? (As far as I can see the main issue is that the dimension of your left minipage is to generous, so you may just reduce6in
to3.5in
unless you want to use other methods such aswrapfig
.)
– marmot
Nov 30 at 1:17
The shading is not there. I replacedred!10
withblack
and nothing happens - the region between the two graphs is not shaded. Do I have to manually download a package onto the hard drive?
– Adelyn
Dec 7 at 17:44
Regarding the follow-up question, I would prefer not to change the margins for anyminipage
environment. What would you suggest for awrapfig
?
– Adelyn
Dec 7 at 17:47
@Adelyn I am sorry, this is the output I am getting on my machine. And I have no idea why it is not there on your machine. And as for your follow-up question, I guess it is better if you place requests there. If you do not accept this answer because it does not give you the desired output, that's perfectly fine. But I cannot really make statements on answers that I did not write.
– marmot
Dec 7 at 19:21
add a comment |
That's a standard task for the fillbetween
library.
documentclass{amsart}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{calc}
usepackage{pgfplots}
pgfplotsset{compat=1.11}
usepgfplotslibrary{fillbetween}
begin{document}
raisebox{0mm}[0mm][0mm]
{
begin{tikzpicture}
begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
axis lines=middle,
xmin=-2,xmax=4, domain=-2:4,
ymin=-0.75,ymax=4,
restrict y to domain=-0.75:4,
xtick={empty},ytick={empty},
axis lines=middle,
axis line style={latex-latex},
xlabel=textit{x},ylabel=textit{y},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
%The graphs of the square root function and the standard parabola are plotted.
addplot[samples=501, domain=-2:2,name path=parabola] {x^2};
addplot[samples=501, domain=0:4,name path=root] {sqrt(x)};
addplot[red!10] fill between [of=parabola and root, soft clip={domain=0:1}];
%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
coordinate (A) at (-15/8,225/64);
coordinate (B) at (-15/16,0);
%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
coordinate (P) at (15/4,{sqrt(15/4)});
coordinate (Q) at (0,{1/4*sqrt(15)});
end{axis}
%A "pin" is drawn to A.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0, font=scriptsize]{makebox[0pt][r]{$y=x^{2}$}};
%A "pin" is drawn to P.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
node[anchor=north, inner sep=0, outer sep=0, font=scriptsize] at ($(P)!0.4cm!90:(Q)$){makebox[0pt][l]{$y=sqrt{x}$}};
end{tikzpicture}
}
end{document}
Please see the response that I posted.
– Adelyn
Nov 30 at 0:05
@Adelyn I just looked at your follow-up question. As far as I can see, the shading does appear there. Is that correct? (As far as I can see the main issue is that the dimension of your left minipage is to generous, so you may just reduce6in
to3.5in
unless you want to use other methods such aswrapfig
.)
– marmot
Nov 30 at 1:17
The shading is not there. I replacedred!10
withblack
and nothing happens - the region between the two graphs is not shaded. Do I have to manually download a package onto the hard drive?
– Adelyn
Dec 7 at 17:44
Regarding the follow-up question, I would prefer not to change the margins for anyminipage
environment. What would you suggest for awrapfig
?
– Adelyn
Dec 7 at 17:47
@Adelyn I am sorry, this is the output I am getting on my machine. And I have no idea why it is not there on your machine. And as for your follow-up question, I guess it is better if you place requests there. If you do not accept this answer because it does not give you the desired output, that's perfectly fine. But I cannot really make statements on answers that I did not write.
– marmot
Dec 7 at 19:21
add a comment |
That's a standard task for the fillbetween
library.
documentclass{amsart}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{calc}
usepackage{pgfplots}
pgfplotsset{compat=1.11}
usepgfplotslibrary{fillbetween}
begin{document}
raisebox{0mm}[0mm][0mm]
{
begin{tikzpicture}
begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
axis lines=middle,
xmin=-2,xmax=4, domain=-2:4,
ymin=-0.75,ymax=4,
restrict y to domain=-0.75:4,
xtick={empty},ytick={empty},
axis lines=middle,
axis line style={latex-latex},
xlabel=textit{x},ylabel=textit{y},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
%The graphs of the square root function and the standard parabola are plotted.
addplot[samples=501, domain=-2:2,name path=parabola] {x^2};
addplot[samples=501, domain=0:4,name path=root] {sqrt(x)};
addplot[red!10] fill between [of=parabola and root, soft clip={domain=0:1}];
%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
coordinate (A) at (-15/8,225/64);
coordinate (B) at (-15/16,0);
%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
coordinate (P) at (15/4,{sqrt(15/4)});
coordinate (Q) at (0,{1/4*sqrt(15)});
end{axis}
%A "pin" is drawn to A.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0, font=scriptsize]{makebox[0pt][r]{$y=x^{2}$}};
%A "pin" is drawn to P.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
node[anchor=north, inner sep=0, outer sep=0, font=scriptsize] at ($(P)!0.4cm!90:(Q)$){makebox[0pt][l]{$y=sqrt{x}$}};
end{tikzpicture}
}
end{document}
That's a standard task for the fillbetween
library.
documentclass{amsart}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{calc}
usepackage{pgfplots}
pgfplotsset{compat=1.11}
usepgfplotslibrary{fillbetween}
begin{document}
raisebox{0mm}[0mm][0mm]
{
begin{tikzpicture}
begin{axis}[width=2.25in, height=2.25in, axis equal image, axis on top, clip=false,
axis lines=middle,
xmin=-2,xmax=4, domain=-2:4,
ymin=-0.75,ymax=4,
restrict y to domain=-0.75:4,
xtick={empty},ytick={empty},
axis lines=middle,
axis line style={latex-latex},
xlabel=textit{x},ylabel=textit{y},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
%The graphs of the square root function and the standard parabola are plotted.
addplot[samples=501, domain=-2:2,name path=parabola] {x^2};
addplot[samples=501, domain=0:4,name path=root] {sqrt(x)};
addplot[red!10] fill between [of=parabola and root, soft clip={domain=0:1}];
%Coordinate A is the point of tangency to the graph of the standard parabola, and B is the
%x-intercept of the tangent line.
coordinate (A) at (-15/8,225/64);
coordinate (B) at (-15/16,0);
%Coordinate P is the point of tangency to the graph of the square root function, and Q is
%the y-intercept of the tangent line.
coordinate (P) at (15/4,{sqrt(15/4)});
coordinate (Q) at (0,{1/4*sqrt(15)});
end{axis}
%A "pin" is drawn to A.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (A) -- ($(A)!0.5cm!-90:(B)$) node[anchor=west, inner sep=0, font=scriptsize]{makebox[0pt][r]{$y=x^{2}$}};
%A "pin" is drawn to P.
draw[draw=gray, shorten <=1mm, shorten >=1mm] (P) -- ($(P)!0.5cm!90:(Q)$);
node[anchor=north, inner sep=0, outer sep=0, font=scriptsize] at ($(P)!0.4cm!90:(Q)$){makebox[0pt][l]{$y=sqrt{x}$}};
end{tikzpicture}
}
end{document}
answered Nov 29 at 19:39
marmot
85.1k495179
85.1k495179
Please see the response that I posted.
– Adelyn
Nov 30 at 0:05
@Adelyn I just looked at your follow-up question. As far as I can see, the shading does appear there. Is that correct? (As far as I can see the main issue is that the dimension of your left minipage is to generous, so you may just reduce6in
to3.5in
unless you want to use other methods such aswrapfig
.)
– marmot
Nov 30 at 1:17
The shading is not there. I replacedred!10
withblack
and nothing happens - the region between the two graphs is not shaded. Do I have to manually download a package onto the hard drive?
– Adelyn
Dec 7 at 17:44
Regarding the follow-up question, I would prefer not to change the margins for anyminipage
environment. What would you suggest for awrapfig
?
– Adelyn
Dec 7 at 17:47
@Adelyn I am sorry, this is the output I am getting on my machine. And I have no idea why it is not there on your machine. And as for your follow-up question, I guess it is better if you place requests there. If you do not accept this answer because it does not give you the desired output, that's perfectly fine. But I cannot really make statements on answers that I did not write.
– marmot
Dec 7 at 19:21
add a comment |
Please see the response that I posted.
– Adelyn
Nov 30 at 0:05
@Adelyn I just looked at your follow-up question. As far as I can see, the shading does appear there. Is that correct? (As far as I can see the main issue is that the dimension of your left minipage is to generous, so you may just reduce6in
to3.5in
unless you want to use other methods such aswrapfig
.)
– marmot
Nov 30 at 1:17
The shading is not there. I replacedred!10
withblack
and nothing happens - the region between the two graphs is not shaded. Do I have to manually download a package onto the hard drive?
– Adelyn
Dec 7 at 17:44
Regarding the follow-up question, I would prefer not to change the margins for anyminipage
environment. What would you suggest for awrapfig
?
– Adelyn
Dec 7 at 17:47
@Adelyn I am sorry, this is the output I am getting on my machine. And I have no idea why it is not there on your machine. And as for your follow-up question, I guess it is better if you place requests there. If you do not accept this answer because it does not give you the desired output, that's perfectly fine. But I cannot really make statements on answers that I did not write.
– marmot
Dec 7 at 19:21
Please see the response that I posted.
– Adelyn
Nov 30 at 0:05
Please see the response that I posted.
– Adelyn
Nov 30 at 0:05
@Adelyn I just looked at your follow-up question. As far as I can see, the shading does appear there. Is that correct? (As far as I can see the main issue is that the dimension of your left minipage is to generous, so you may just reduce
6in
to 3.5in
unless you want to use other methods such as wrapfig
.)– marmot
Nov 30 at 1:17
@Adelyn I just looked at your follow-up question. As far as I can see, the shading does appear there. Is that correct? (As far as I can see the main issue is that the dimension of your left minipage is to generous, so you may just reduce
6in
to 3.5in
unless you want to use other methods such as wrapfig
.)– marmot
Nov 30 at 1:17
The shading is not there. I replaced
red!10
with black
and nothing happens - the region between the two graphs is not shaded. Do I have to manually download a package onto the hard drive?– Adelyn
Dec 7 at 17:44
The shading is not there. I replaced
red!10
with black
and nothing happens - the region between the two graphs is not shaded. Do I have to manually download a package onto the hard drive?– Adelyn
Dec 7 at 17:44
Regarding the follow-up question, I would prefer not to change the margins for any
minipage
environment. What would you suggest for a wrapfig
?– Adelyn
Dec 7 at 17:47
Regarding the follow-up question, I would prefer not to change the margins for any
minipage
environment. What would you suggest for a wrapfig
?– Adelyn
Dec 7 at 17:47
@Adelyn I am sorry, this is the output I am getting on my machine. And I have no idea why it is not there on your machine. And as for your follow-up question, I guess it is better if you place requests there. If you do not accept this answer because it does not give you the desired output, that's perfectly fine. But I cannot really make statements on answers that I did not write.
– marmot
Dec 7 at 19:21
@Adelyn I am sorry, this is the output I am getting on my machine. And I have no idea why it is not there on your machine. And as for your follow-up question, I guess it is better if you place requests there. If you do not accept this answer because it does not give you the desired output, that's perfectly fine. But I cannot really make statements on answers that I did not write.
– marmot
Dec 7 at 19:21
add a comment |
Thanks for contributing an answer to TeX - LaTeX 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.
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.
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%2ftex.stackexchange.com%2fquestions%2f462448%2fshading-the-region-bound-by-two-graphs%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
1
This is the code for a typical plot seen in a Calculus course.
– user143462
Nov 29 at 19:28