In [39]:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 100)
y = np.cos(x), np.cos(x + 1), np.cos(x + 2)
names = ['Signal 1', 'Signal 2', 'Signal 3']
In [19]:
fig, axes = plt.subplots(nrows=3, ncols=1)
for f, name, ax in zip(y, names, axes):
ax.plot(x, f, color='k')
ax.set(xticks=[], yticks=[], title=name, xlim=(0, 10))
plt.tight_layout()
plt.show()
Here is some code to start with:
In [20]:
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(1)
# Generate data...
y_raw = np.random.randn(1000).cumsum() + 15
x_raw = np.linspace(0, 24, y_raw.size)
# Get averages of every 100 samples...
x_pos = x_raw.reshape(-1, 100).min(axis=1)
y_avg = y_raw.reshape(-1, 100).mean(axis=1)
y_err = y_raw.reshape(-1, 100).ptp(axis=1)
bar_width = x_pos[1] - x_pos[0]
# Make a made up future prediction with a fake confidence
x_pred = np.linspace(0, 30)
y_max_pred = y_avg[0] + y_err[0] + 2.3 * x_pred
y_min_pred = y_avg[0] - y_err[0] + 1.2 * x_pred
# Just so you don't have to guess at the colors...
barcolor, linecolor, fillcolor = 'wheat', 'salmon', 'lightblue'
# Now you're on your own!
In [92]:
fig, axis = plt.subplots()
axis.set(xlim=(0, 30), xlabel='Minutes since class began', ylabel='Snarkiness (snark units)')
axis.plot(x_raw, y_raw, color=linecolor)
axis.bar(x_pos, y_avg, width=bar_width, edgecolor='grey', color=barcolor, yerr=y_err, ecolor='grey', capsize=3, align='edge')
axis.fill_between(x_pred, y_min_pred, y_max_pred, color=fillcolor)
plt.show()
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: