Skip to content

Instantly share code, notes, and snippets.

@BowenFu
BowenFu / envelope.py
Created January 5, 2017 02:43
matplotlib- amplitude envelope
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import hilbert, chirp
duration = 1.0
fs = 400.0
samples = int(fs*duration)
t = np.arange(samples) / fs
signal = chirp(t, 20.0, t[-1], 100.0)
@BowenFu
BowenFu / offset_text.py
Created November 30, 2016 13:25 — forked from alexpearce/offset_text.py
Nice offset label formatting in matplotlib. See [the blog post](https://alexpearce.me/2014/04/exponent-label-in-matplotlib/) for more.
import numpy as np
from matplotlib import pyplot as plt
fig = plt.figure(figsize=(5, 4))
# Generate some data
mu, sigma = 1e7, 1e6
s = np.random.normal(mu, sigma, 10000)
# Plot it
plt.hist(s, 30, histtype='step')
# Format it