Last active
January 4, 2020 06:06
-
-
Save Perishleaf/892d0728a2e308d15e47df8cd90688d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
# set up a seed to make the random result reproducible | |
np.random.seed(seed=666) | |
# create some data to use for the plot | |
dt = 0.001 | |
t = np.arange(0.0, 10.0, dt) | |
r = np.exp(-t[:1000]/0.05) # impulse response | |
x = np.random.randn(len(t)) | |
s = np.convolve(x, r)[:len(x)]*dt # colored noise | |
# set up subplot axes | |
fig = plt.figure() | |
ax1 = fig.add_subplot(1, 1, 1) | |
ax2 = fig.add_axes([0.2, 0.6, .2, .2], facecolor='y') | |
ax3 = fig.add_axes([.65, .6, .2, .2], facecolor='y') | |
# the main axes | |
ax1.plot(t, s) | |
ax1.axis([0, 1, 1.1*np.amin(s), 2*np.amax(s)]) | |
ax1.set_xlabel('time (s)') | |
ax1.set_ylabel('current (nA)') | |
ax1.set_title('Gaussian colored noise') | |
# this is another inset axes over the main axes | |
ax2.plot(t[:len(r)], r) | |
ax2.set_title('Impulse response') | |
ax2.set_xlim(0, 0.2) | |
ax2.set_xticks([]) | |
ax2.set_yticks([]) | |
# this is an inset axes over the main axes | |
n, bins, patches = ax3.hist(s, 400, density=1) | |
ax3.set_title('Probability') | |
ax3.set_xticks([]) | |
ax3.set_yticks([]) | |
fig.canvas.draw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment