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.
Asked
Active
Viewed 1,237 times
0
-
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 Answers
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?

hd1
- 33,938
- 5
- 80
- 91
-
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 03: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