Skip to content

Instantly share code, notes, and snippets.

@gocreating
Created October 16, 2016 18:20
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 gocreating/97fe750b7f0de2c7b20ea2f137cc7f0c to your computer and use it in GitHub Desktop.
Save gocreating/97fe750b7f0de2c7b20ea2f137cc7f0c to your computer and use it in GitHub Desktop.
# coding=UTF-8
import sys
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
mpl.rcParams['agg.path.chunksize'] = 10000
FILES = [
'./Channel4_20161004083134734.csv',
'./Channel5_20161004083153218.csv',
'./Channel6_20161004083208828.csv',
]
maxRows = 700000
if len(sys.argv) > 1:
maxRows = int(sys.argv[1])
for filename in FILES:
title = filename.replace('./', '').replace('.csv', '')
# ref: <http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html>
data = np.genfromtxt(
filename,
delimiter=',',
skip_header=0,
skip_footer=0,
names=['time', 'phase'],
max_rows=maxRows
)
x = data['time']
y = data['phase']
plt.plot(x,y)
# 設定圖的範圍, 不設的話,系統會自行決定
rows = len(x)
plt.xlim(0, float(rows) * 0.5555)
plt.ylim(-4, 4)
plt.xlabel("time")
plt.ylabel("phase")
plt.title(title + '(' + str(rows) + ' records)')
# plt.show()
plt.savefig('./plots/' + str(rows) + '_' + title + '.jpg', dpi=300, format='jpg')
plt.clf()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment