In [1]:
import pandas as pd
import numpy as np
import scipy.signal as signal
from multiplot import PandasPlot, NumpyPlot
%matplotlib inline
Generate a set of sample signals.
In [2]:
samp_freq = 1000 # Hz
duration = 5 # seconds
first_signal_freq =1 # Hz
signals = []
labels = []
for x in xrange(1,6):
signal_freq = first_signal_freq * x
time_points = np.arange(0, duration, 1/float(samp_freq))
sig = np.sin(2 * np.pi * signal_freq * time_points)
sig_label = "Ch %d" %(x-1)
labels.append(sig_label)
signals.append(sig)
df = pd.DataFrame(np.transpose(signals), columns=labels)
nump = np.array(signals)
Note that PandasPlot expects a DataFrame where each series is a column, whereas NumpyPlot expects an array where each series is a row.
In [3]:
print 'DataFrame: ', df.shape
print 'Numpy array: ', nump.shape
In [4]:
PandasPlot(df)
Out[4]:
In [5]:
NumpyPlot(nump, labels=labels) # if labels aren't supplied, 'Ch x' labels are auto-generated
Out[5]:
In [6]:
PandasPlot(df, num_display_chans=2)
Out[6]:
In [7]:
PandasPlot(df, num_display_samps=2000)
Out[7]:
In [8]:
highlights = {'Ch 0': [[2000, 3000]],
'Ch 2': [[1000, 2000], [3000, 4000]],
'Ch 4': [[2000, 3000]]}
PandasPlot(df, highlights=highlights)
Out[8]: