Skip to content

Instantly share code, notes, and snippets.

@RyanFleck
Created February 11, 2020 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyanFleck/3a5c689b99fcbb0b952bf9202d811f10 to your computer and use it in GitHub Desktop.
Save RyanFleck/3a5c689b99fcbb0b952bf9202d811f10 to your computer and use it in GitHub Desktop.
Given a folder of CSV files, return a .png for each with the plotted values.
import numpy as np
import matplotlib.pyplot as plt
import csv
import glob
import os
print("Gathering CSVs...")
csvFiles = sorted(glob.glob(os.getcwd() + "/*.csv"))
numpyFileData = []
fig = 1
for x in csvFiles:
print("Found " + x)
filename = os.path.splitext(os.path.basename(x))[0]
saveto = "{}.png".format(filename)
ms, SmV, mrad, RmV, CmV = np.loadtxt(
x, delimiter=',', skiprows=1, unpack=True)
plt.title("Amplitude {}".format(fig))
plt.plot(ms, mrad, marker='x')
plt.xlabel('x axis label')
plt.ylabel('y axis label')
print("Saving graph to {}".format(saveto))
plt.savefig(saveto, bbox_inches='tight')
plt.clf()
fig = fig + 0.5
# Time (ms) | Raw speed error (mV) | Raw speed (mrad/s) | Reference (mV) |
# Control output (mV)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment