python plot with mean/standard deviation (maybe R?)












0















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.



enter image description here










share|improve this question

























  • 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
















0















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.



enter image description here










share|improve this question

























  • 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














0












0








0


1






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.



enter image description here










share|improve this question
















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.



enter image description here







python data-visualization stochastic-process






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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












1 Answer
1






active

oldest

votes


















0














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?



Resulting plot from code above






share|improve this answer


























  • 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











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


}
});














draft saved

draft discarded


















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









0














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?



Resulting plot from code above






share|improve this answer


























  • 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
















0














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?



Resulting plot from code above






share|improve this answer


























  • 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














0












0








0







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?



Resulting plot from code above






share|improve this answer















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?



Resulting plot from code above







share|improve this answer














share|improve this answer



share|improve this answer








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



















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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

Full-time equivalent

Bicuculline

さくらももこ