python plot with mean/standard deviation (maybe R?)
Hi I'm trying to produce a plot with the mean and standard deviation marked for a single realization of a random process as in the linked diagram. I've looked at python charting but can't find any packages that produce a similar plot.
python data-visualization stochastic-process
add a comment |
Hi I'm trying to produce a plot with the mean and standard deviation marked for a single realization of a random process as in the linked diagram. I've looked at python charting but can't find any packages that produce a similar plot.
python data-visualization stochastic-process
Do you know the mean and standard deviation for the process already? Python can't just find the mean and std deviation given one realization without you supplying it more information. Is your question more like how to plot 4 line on one graph?
– jwil
Nov 15 '18 at 20:06
add a comment |
Hi I'm trying to produce a plot with the mean and standard deviation marked for a single realization of a random process as in the linked diagram. I've looked at python charting but can't find any packages that produce a similar plot.
python data-visualization stochastic-process
Hi I'm trying to produce a plot with the mean and standard deviation marked for a single realization of a random process as in the linked diagram. I've looked at python charting but can't find any packages that produce a similar plot.
python data-visualization stochastic-process
python data-visualization stochastic-process
edited Nov 13 '18 at 3:41
Aqueous Carlos
293213
293213
asked Nov 13 '18 at 2:58
user171006user171006
1
1
Do you know the mean and standard deviation for the process already? Python can't just find the mean and std deviation given one realization without you supplying it more information. Is your question more like how to plot 4 line on one graph?
– jwil
Nov 15 '18 at 20:06
add a comment |
Do you know the mean and standard deviation for the process already? Python can't just find the mean and std deviation given one realization without you supplying it more information. Is your question more like how to plot 4 line on one graph?
– jwil
Nov 15 '18 at 20:06
Do you know the mean and standard deviation for the process already? Python can't just find the mean and std deviation given one realization without you supplying it more information. Is your question more like how to plot 4 line on one graph?
– jwil
Nov 15 '18 at 20:06
Do you know the mean and standard deviation for the process already? Python can't just find the mean and std deviation given one realization without you supplying it more information. Is your question more like how to plot 4 line on one graph?
– jwil
Nov 15 '18 at 20:06
add a comment |
1 Answer
1
active
oldest
votes
import numpy as np
import matplotlib.pyplot as plt
xs = np.linspace(-np.pi, np.pi, 30)
ys = np.sin(xs)
plt.plot(xs, xs, ys, '-gD')
plt.title('Standard Deviation: %s; marker represents the average of the data (%s)' % (np.mean(ys), np.std(ys)))
Does that work for you?
HI Claire- thanks for your response. I had to change numpy.mean to np.mean and then while plotting I got the following error: IndexError: only integers, slices (:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices
– user171006
Nov 15 '18 at 3:05
@user171006 It runs fine on python 3.7.1 on Mac OS X Mojave. I've also enclosed a plot sample.
– hd1
Nov 15 '18 at 20:11
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fstackoverflow.com%2fquestions%2f53273145%2fpython-plot-with-mean-standard-deviation-maybe-r%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
import numpy as np
import matplotlib.pyplot as plt
xs = np.linspace(-np.pi, np.pi, 30)
ys = np.sin(xs)
plt.plot(xs, xs, ys, '-gD')
plt.title('Standard Deviation: %s; marker represents the average of the data (%s)' % (np.mean(ys), np.std(ys)))
Does that work for you?
HI Claire- thanks for your response. I had to change numpy.mean to np.mean and then while plotting I got the following error: IndexError: only integers, slices (:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices
– user171006
Nov 15 '18 at 3:05
@user171006 It runs fine on python 3.7.1 on Mac OS X Mojave. I've also enclosed a plot sample.
– hd1
Nov 15 '18 at 20:11
add a comment |
import numpy as np
import matplotlib.pyplot as plt
xs = np.linspace(-np.pi, np.pi, 30)
ys = np.sin(xs)
plt.plot(xs, xs, ys, '-gD')
plt.title('Standard Deviation: %s; marker represents the average of the data (%s)' % (np.mean(ys), np.std(ys)))
Does that work for you?
HI Claire- thanks for your response. I had to change numpy.mean to np.mean and then while plotting I got the following error: IndexError: only integers, slices (:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices
– user171006
Nov 15 '18 at 3:05
@user171006 It runs fine on python 3.7.1 on Mac OS X Mojave. I've also enclosed a plot sample.
– hd1
Nov 15 '18 at 20:11
add a comment |
import numpy as np
import matplotlib.pyplot as plt
xs = np.linspace(-np.pi, np.pi, 30)
ys = np.sin(xs)
plt.plot(xs, xs, ys, '-gD')
plt.title('Standard Deviation: %s; marker represents the average of the data (%s)' % (np.mean(ys), np.std(ys)))
Does that work for you?
import numpy as np
import matplotlib.pyplot as plt
xs = np.linspace(-np.pi, np.pi, 30)
ys = np.sin(xs)
plt.plot(xs, xs, ys, '-gD')
plt.title('Standard Deviation: %s; marker represents the average of the data (%s)' % (np.mean(ys), np.std(ys)))
Does that work for you?
edited Nov 15 '18 at 20:10
answered Nov 13 '18 at 3:18
hd1hd1
24.4k35568
24.4k35568
HI Claire- thanks for your response. I had to change numpy.mean to np.mean and then while plotting I got the following error: IndexError: only integers, slices (:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices
– user171006
Nov 15 '18 at 3:05
@user171006 It runs fine on python 3.7.1 on Mac OS X Mojave. I've also enclosed a plot sample.
– hd1
Nov 15 '18 at 20:11
add a comment |
HI Claire- thanks for your response. I had to change numpy.mean to np.mean and then while plotting I got the following error: IndexError: only integers, slices (:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices
– user171006
Nov 15 '18 at 3:05
@user171006 It runs fine on python 3.7.1 on Mac OS X Mojave. I've also enclosed a plot sample.
– hd1
Nov 15 '18 at 20:11
HI Claire- thanks for your response. I had to change numpy.mean to np.mean and then while plotting I got the following error: IndexError: only integers, slices (
:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices– user171006
Nov 15 '18 at 3:05
HI Claire- thanks for your response. I had to change numpy.mean to np.mean and then while plotting I got the following error: IndexError: only integers, slices (
:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices– user171006
Nov 15 '18 at 3:05
@user171006 It runs fine on python 3.7.1 on Mac OS X Mojave. I've also enclosed a plot sample.
– hd1
Nov 15 '18 at 20:11
@user171006 It runs fine on python 3.7.1 on Mac OS X Mojave. I've also enclosed a plot sample.
– hd1
Nov 15 '18 at 20:11
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f53273145%2fpython-plot-with-mean-standard-deviation-maybe-r%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
Do you know the mean and standard deviation for the process already? Python can't just find the mean and std deviation given one realization without you supplying it more information. Is your question more like how to plot 4 line on one graph?
– jwil
Nov 15 '18 at 20:06