Skip to content

Instantly share code, notes, and snippets.

@gocreating gocreating/plot.py
Created Oct 16, 2016

Embed
What would you like to do?
# 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
You can’t perform that action at this time.