How to plot a function
Hello I am new to this stackexchange, and I have a question in regards to how one plots a function. I have done research, and I have seen this question:
The Question
I have even tried programming it but it does not come up, and the function I would like to graph, and generally learn how to plot any function is the sqrt(9-x)^.5
Here is the bit of code which I have been working on:
usepackage{amsmath}
usepackage{amssymb}
usepackage{graphics}
usepackage{graphicx}
usepackage{pgfplots}
usepackage{subfigure}
usepackage{tikz}
usepackage{pgfplots}
usepackage{subfigure}
begin{figure}
centering
subfigure
{
begin{tikzpicture}
begin{axis}[xmin=-1.5,ymin=-1.5,ymax=1.5]
addplot+[domain=0.0001:1.5,unbounded coords=jump,samples=301] {(9-x)^(0.5)};
addlegendentry{$f(x)=sqrt{x}$}
end{axis}
end{tikzpicture}
}
%
end{figure}
Thank you very much.
graphics graphs
add a comment |
Hello I am new to this stackexchange, and I have a question in regards to how one plots a function. I have done research, and I have seen this question:
The Question
I have even tried programming it but it does not come up, and the function I would like to graph, and generally learn how to plot any function is the sqrt(9-x)^.5
Here is the bit of code which I have been working on:
usepackage{amsmath}
usepackage{amssymb}
usepackage{graphics}
usepackage{graphicx}
usepackage{pgfplots}
usepackage{subfigure}
usepackage{tikz}
usepackage{pgfplots}
usepackage{subfigure}
begin{figure}
centering
subfigure
{
begin{tikzpicture}
begin{axis}[xmin=-1.5,ymin=-1.5,ymax=1.5]
addplot+[domain=0.0001:1.5,unbounded coords=jump,samples=301] {(9-x)^(0.5)};
addlegendentry{$f(x)=sqrt{x}$}
end{axis}
end{tikzpicture}
}
%
end{figure}
Thank you very much.
graphics graphs
1
(1) welcome, (2) It will be beneficial to others if you extend this to a full by minimal document. Then it is easier to for example verify that you have loaded the necessary packages in you preamble for this example to work
– daleif
Feb 11 at 20:20
@marmot its the sqrt{9-x}
– EnlightenedFunky
Feb 11 at 21:35
@daleif There are all the packages
– EnlightenedFunky
Feb 11 at 21:39
2
That is not a minimal example, there is no documentclass and no begin/end document
– daleif
Feb 11 at 21:42
add a comment |
Hello I am new to this stackexchange, and I have a question in regards to how one plots a function. I have done research, and I have seen this question:
The Question
I have even tried programming it but it does not come up, and the function I would like to graph, and generally learn how to plot any function is the sqrt(9-x)^.5
Here is the bit of code which I have been working on:
usepackage{amsmath}
usepackage{amssymb}
usepackage{graphics}
usepackage{graphicx}
usepackage{pgfplots}
usepackage{subfigure}
usepackage{tikz}
usepackage{pgfplots}
usepackage{subfigure}
begin{figure}
centering
subfigure
{
begin{tikzpicture}
begin{axis}[xmin=-1.5,ymin=-1.5,ymax=1.5]
addplot+[domain=0.0001:1.5,unbounded coords=jump,samples=301] {(9-x)^(0.5)};
addlegendentry{$f(x)=sqrt{x}$}
end{axis}
end{tikzpicture}
}
%
end{figure}
Thank you very much.
graphics graphs
Hello I am new to this stackexchange, and I have a question in regards to how one plots a function. I have done research, and I have seen this question:
The Question
I have even tried programming it but it does not come up, and the function I would like to graph, and generally learn how to plot any function is the sqrt(9-x)^.5
Here is the bit of code which I have been working on:
usepackage{amsmath}
usepackage{amssymb}
usepackage{graphics}
usepackage{graphicx}
usepackage{pgfplots}
usepackage{subfigure}
usepackage{tikz}
usepackage{pgfplots}
usepackage{subfigure}
begin{figure}
centering
subfigure
{
begin{tikzpicture}
begin{axis}[xmin=-1.5,ymin=-1.5,ymax=1.5]
addplot+[domain=0.0001:1.5,unbounded coords=jump,samples=301] {(9-x)^(0.5)};
addlegendentry{$f(x)=sqrt{x}$}
end{axis}
end{tikzpicture}
}
%
end{figure}
Thank you very much.
graphics graphs
graphics graphs
edited Feb 11 at 21:39
EnlightenedFunky
asked Feb 11 at 20:11
EnlightenedFunkyEnlightenedFunky
1085
1085
1
(1) welcome, (2) It will be beneficial to others if you extend this to a full by minimal document. Then it is easier to for example verify that you have loaded the necessary packages in you preamble for this example to work
– daleif
Feb 11 at 20:20
@marmot its the sqrt{9-x}
– EnlightenedFunky
Feb 11 at 21:35
@daleif There are all the packages
– EnlightenedFunky
Feb 11 at 21:39
2
That is not a minimal example, there is no documentclass and no begin/end document
– daleif
Feb 11 at 21:42
add a comment |
1
(1) welcome, (2) It will be beneficial to others if you extend this to a full by minimal document. Then it is easier to for example verify that you have loaded the necessary packages in you preamble for this example to work
– daleif
Feb 11 at 20:20
@marmot its the sqrt{9-x}
– EnlightenedFunky
Feb 11 at 21:35
@daleif There are all the packages
– EnlightenedFunky
Feb 11 at 21:39
2
That is not a minimal example, there is no documentclass and no begin/end document
– daleif
Feb 11 at 21:42
1
1
(1) welcome, (2) It will be beneficial to others if you extend this to a full by minimal document. Then it is easier to for example verify that you have loaded the necessary packages in you preamble for this example to work
– daleif
Feb 11 at 20:20
(1) welcome, (2) It will be beneficial to others if you extend this to a full by minimal document. Then it is easier to for example verify that you have loaded the necessary packages in you preamble for this example to work
– daleif
Feb 11 at 20:20
@marmot its the sqrt{9-x}
– EnlightenedFunky
Feb 11 at 21:35
@marmot its the sqrt{9-x}
– EnlightenedFunky
Feb 11 at 21:35
@daleif There are all the packages
– EnlightenedFunky
Feb 11 at 21:39
@daleif There are all the packages
– EnlightenedFunky
Feb 11 at 21:39
2
2
That is not a minimal example, there is no documentclass and no begin/end document
– daleif
Feb 11 at 21:42
That is not a minimal example, there is no documentclass and no begin/end document
– daleif
Feb 11 at 21:42
add a comment |
1 Answer
1
active
oldest
votes
Welcome to TeX.SE! This is an attempt to summarize some aspects of the comments by @daleif and myself.
- You got an empty plot because you set
ymax=1.5
but the function assumes larger values in the domain you are plotting it, so you effectively clip the plot away. - You are using the
subfigure
package. It is generally recommended to use thesubcaption
package instead. - Your code does not quite make an MWE. As pointed out by @daleif, it is lacking a
documentclass
as well asbegin{document}
andend{document}
. And you are loading packages multiple times, andpgfplots
already loadstikz
, which loadsgraphicx
.
This qualifies as a MWE and takes into account the above points.
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{subcaption}
begin{document}
begin{figure}[htb]
centering
begin{subfigure}{0.5textwidth}
centering
begin{tikzpicture}
begin{axis}[xmin=-0.1,xmax=1.6,ymin=1.5,ymax=3.5,
xlabel={$x$},ylabel={$f(x)$}]
addplot+[domain=0.0001:1.5,unbounded coords=jump,samples=301] {(9-x)^(0.5)};
addlegendentry{$f(x)=sqrt{9-x}$}
end{axis}
end{tikzpicture}
caption{Caption of a figure.}
label{fig:ASubFigure}
end{subfigure}
caption{Caption of a figure.}
label{fig:AFigure}
end{figure}
Figure~ref{fig:ASubFigure} is a subfigure of figure~ref{fig:AFigure}.
end{document}
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%2f474405%2fhow-to-plot-a-function%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
Welcome to TeX.SE! This is an attempt to summarize some aspects of the comments by @daleif and myself.
- You got an empty plot because you set
ymax=1.5
but the function assumes larger values in the domain you are plotting it, so you effectively clip the plot away. - You are using the
subfigure
package. It is generally recommended to use thesubcaption
package instead. - Your code does not quite make an MWE. As pointed out by @daleif, it is lacking a
documentclass
as well asbegin{document}
andend{document}
. And you are loading packages multiple times, andpgfplots
already loadstikz
, which loadsgraphicx
.
This qualifies as a MWE and takes into account the above points.
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{subcaption}
begin{document}
begin{figure}[htb]
centering
begin{subfigure}{0.5textwidth}
centering
begin{tikzpicture}
begin{axis}[xmin=-0.1,xmax=1.6,ymin=1.5,ymax=3.5,
xlabel={$x$},ylabel={$f(x)$}]
addplot+[domain=0.0001:1.5,unbounded coords=jump,samples=301] {(9-x)^(0.5)};
addlegendentry{$f(x)=sqrt{9-x}$}
end{axis}
end{tikzpicture}
caption{Caption of a figure.}
label{fig:ASubFigure}
end{subfigure}
caption{Caption of a figure.}
label{fig:AFigure}
end{figure}
Figure~ref{fig:ASubFigure} is a subfigure of figure~ref{fig:AFigure}.
end{document}
add a comment |
Welcome to TeX.SE! This is an attempt to summarize some aspects of the comments by @daleif and myself.
- You got an empty plot because you set
ymax=1.5
but the function assumes larger values in the domain you are plotting it, so you effectively clip the plot away. - You are using the
subfigure
package. It is generally recommended to use thesubcaption
package instead. - Your code does not quite make an MWE. As pointed out by @daleif, it is lacking a
documentclass
as well asbegin{document}
andend{document}
. And you are loading packages multiple times, andpgfplots
already loadstikz
, which loadsgraphicx
.
This qualifies as a MWE and takes into account the above points.
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{subcaption}
begin{document}
begin{figure}[htb]
centering
begin{subfigure}{0.5textwidth}
centering
begin{tikzpicture}
begin{axis}[xmin=-0.1,xmax=1.6,ymin=1.5,ymax=3.5,
xlabel={$x$},ylabel={$f(x)$}]
addplot+[domain=0.0001:1.5,unbounded coords=jump,samples=301] {(9-x)^(0.5)};
addlegendentry{$f(x)=sqrt{9-x}$}
end{axis}
end{tikzpicture}
caption{Caption of a figure.}
label{fig:ASubFigure}
end{subfigure}
caption{Caption of a figure.}
label{fig:AFigure}
end{figure}
Figure~ref{fig:ASubFigure} is a subfigure of figure~ref{fig:AFigure}.
end{document}
add a comment |
Welcome to TeX.SE! This is an attempt to summarize some aspects of the comments by @daleif and myself.
- You got an empty plot because you set
ymax=1.5
but the function assumes larger values in the domain you are plotting it, so you effectively clip the plot away. - You are using the
subfigure
package. It is generally recommended to use thesubcaption
package instead. - Your code does not quite make an MWE. As pointed out by @daleif, it is lacking a
documentclass
as well asbegin{document}
andend{document}
. And you are loading packages multiple times, andpgfplots
already loadstikz
, which loadsgraphicx
.
This qualifies as a MWE and takes into account the above points.
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{subcaption}
begin{document}
begin{figure}[htb]
centering
begin{subfigure}{0.5textwidth}
centering
begin{tikzpicture}
begin{axis}[xmin=-0.1,xmax=1.6,ymin=1.5,ymax=3.5,
xlabel={$x$},ylabel={$f(x)$}]
addplot+[domain=0.0001:1.5,unbounded coords=jump,samples=301] {(9-x)^(0.5)};
addlegendentry{$f(x)=sqrt{9-x}$}
end{axis}
end{tikzpicture}
caption{Caption of a figure.}
label{fig:ASubFigure}
end{subfigure}
caption{Caption of a figure.}
label{fig:AFigure}
end{figure}
Figure~ref{fig:ASubFigure} is a subfigure of figure~ref{fig:AFigure}.
end{document}
Welcome to TeX.SE! This is an attempt to summarize some aspects of the comments by @daleif and myself.
- You got an empty plot because you set
ymax=1.5
but the function assumes larger values in the domain you are plotting it, so you effectively clip the plot away. - You are using the
subfigure
package. It is generally recommended to use thesubcaption
package instead. - Your code does not quite make an MWE. As pointed out by @daleif, it is lacking a
documentclass
as well asbegin{document}
andend{document}
. And you are loading packages multiple times, andpgfplots
already loadstikz
, which loadsgraphicx
.
This qualifies as a MWE and takes into account the above points.
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{subcaption}
begin{document}
begin{figure}[htb]
centering
begin{subfigure}{0.5textwidth}
centering
begin{tikzpicture}
begin{axis}[xmin=-0.1,xmax=1.6,ymin=1.5,ymax=3.5,
xlabel={$x$},ylabel={$f(x)$}]
addplot+[domain=0.0001:1.5,unbounded coords=jump,samples=301] {(9-x)^(0.5)};
addlegendentry{$f(x)=sqrt{9-x}$}
end{axis}
end{tikzpicture}
caption{Caption of a figure.}
label{fig:ASubFigure}
end{subfigure}
caption{Caption of a figure.}
label{fig:AFigure}
end{figure}
Figure~ref{fig:ASubFigure} is a subfigure of figure~ref{fig:AFigure}.
end{document}
edited Feb 12 at 2:20
answered Feb 12 at 1:22
marmotmarmot
101k4117226
101k4117226
add a comment |
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.
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%2f474405%2fhow-to-plot-a-function%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
(1) welcome, (2) It will be beneficial to others if you extend this to a full by minimal document. Then it is easier to for example verify that you have loaded the necessary packages in you preamble for this example to work
– daleif
Feb 11 at 20:20
@marmot its the sqrt{9-x}
– EnlightenedFunky
Feb 11 at 21:35
@daleif There are all the packages
– EnlightenedFunky
Feb 11 at 21:39
2
That is not a minimal example, there is no documentclass and no begin/end document
– daleif
Feb 11 at 21:42