Skip to content

Instantly share code, notes, and snippets.

@rjzak
Created November 1, 2016 16:31
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 rjzak/3ef956e72133871e435797d101734994 to your computer and use it in GitHub Desktop.
Save rjzak/3ef956e72133871e435797d101734994 to your computer and use it in GitHub Desktop.
A quick and simple Python script to graph numpy arrays. Useful for initial analysis and comparing of data.
#!/usr/bin/python
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
import sys
# Modeled after: http://matplotlib.org/1.3.0/examples/pylab_examples/legend_demo.html
if len(sys.argv) < 2:
print("Usage: %s <File1>...<FileN>" % sys.argv[0])
sys.exit(1)
fig, ax = plt.subplots()
for arg in sys.argv[1:]:
d = np.fromfile(arg)
ax.plot(d, label=arg)
legend = ax.legend(loc='upper center', shadow=True)
frame = legend.get_frame()
frame.set_facecolor('0.90')
for label in legend.get_texts():
label.set_fontsize('small')
for label in legend.get_lines():
label.set_linewidth(1.0)
plt.show()
plt.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment