Source code for allensdk.brain_observatory.visualization

import matplotlib.pyplot as plt

[docs]def plot_running_speed( timestamps, values, start_index=0, stop_index=None, step=1, ylabel='running speed (cm/s)', xlabel='time (s)', title=None ): # pragma: no cover ''' Make a simple plot of a running speed trace Parameters ---------- timestamps : numpy.ndarray Times at which running speed samples were collected values : numpy.ndarray Running speed values (by default: linear cm / s with negative values indicating backwards movement) ''' stop_index = len(timestamps) if stop_index is None else stop_index if title is None: title = f'running speed from {timestamps[start_index]:2.2f} to {timestamps[stop_index-1]:2.2f} seconds' fig, ax = plt.subplots(figsize=(8, 8)) plt.plot( timestamps[start_index:stop_index:step], values[start_index:stop_index:step], ) ax.set_ylabel(ylabel, fontsize=16) ax.set_xlabel(xlabel, fontsize=16) ax.set_title(title, fontsize=20) plt.axis('tight') return fig