Created
November 29, 2017 03:14
-
-
Save ifd3f/60abd485b1ac17542ca7b85c642206e4 to your computer and use it in GitHub Desktop.
Plot CSV file(s) describing PID output.
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 | |
from matplotlib import gridspec | |
import sys | |
import pandas as pd | |
paths = sys.argv.copy() | |
del paths[0] | |
count = len(paths) | |
gs = gridspec.GridSpec(count, 1) | |
last_ax = None | |
for i, path in enumerate(paths): | |
df = pd.read_csv(path, error_bad_lines=False) | |
time = df['times'] | |
target = df['target'] | |
positions = df['positions'] | |
ax = plt.subplot(gs[i], sharex=last_ax) | |
ax.set_title(path) | |
ax.set_xlabel('time (s)') | |
ax.set_ylabel('ticks') | |
line_targ, line_pos = ax.plot(time, target, 'b--', time, positions, 'g') | |
ax.legend((line_targ, line_pos), ('target', 'position'), loc='lower right') | |
last_ax = ax | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment