Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3.5
- import numpy as np
- import matplotlib.pyplot as plt
- import sys
- #print (sys.argv)
- #quit()
- if (len(sys.argv) > 1):
- fname = sys.argv[1]
- else:
- print("Usage: "+sys.argv[0]+" datafile Xcolumn[default 0] Ycolumn[default 1] NumLinestoSkip[default 0] NumAverage[default 1, no averaging]")
- quit()
- if (len(sys.argv) > 3):
- xcol = int(sys.argv[2])
- ycol = int(sys.argv[3])
- else:
- xcol = 0
- ycol = 1
- if (len(sys.argv) > 4):
- skip = int(sys.argv[4])
- else:
- skip = 0
- if (len(sys.argv) > 5):
- sum_count = int(sys.argv[5])
- else:
- sum_count = 1
- x, y = np.loadtxt(fname, skiprows=skip, usecols=(xcol, ycol), unpack=True)
- xx = []
- yy = []
- for j in range(0, len(x)//sum_count):
- xx.append(x[j*sum_count])
- yy.append(np.average(y[j*sum_count:j*sum_count+sum_count]))
- fig = plt.figure()
- ax1 = fig.add_subplot(111)
- ax1.set_title(fname+" data")
- ax1.set_xlabel('X')
- ax1.set_ylabel('Y')
- ax1.plot(xx, yy, color='r', marker='+', markeredgecolor='black', label='the data')
- leg = ax1.legend()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement