elkclone

2dplotter1.1.py

Feb 19th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. #!usr/bin/python
  2. #http://reasearch4.org
  3.  
  4.  
  5. #Simple 2dplotter.py that asks for a file input of comma separated data or txt file.
  6. #you can change the hard coding of the ax1.set_xlabel and _ylabel and title of graph.
  7. #the file to import must be in the local directory where you run the script from
  8. #if you dont enter the full path at the script raw_imput prompt. =^^=
  9.  
  10. import matplotlib.pyplot as plt
  11. import numpy as np
  12.  
  13. fileName = raw_input('enter the filename to plot,txt or csv --->')
  14. def graphex():
  15.     x = []
  16.     y = []
  17.     readFile = open(fileName, 'r')
  18.     sepFile = readFile.read().split('\n')
  19.     readFile.close()
  20.  
  21.     fig = plt.figure()
  22.     rect = fig.patch
  23.     rect.set_facecolor('blue')
  24.  
  25.     for plotPair in sepFile:
  26.         xandy = plotPair.split(',')
  27.         x.append(int(xandy[0]))
  28.         y.append(int(xandy[1]))
  29.    
  30.     ax1 = fig.add_subplot(1,1,1, axisbg='grey')
  31.     ax1.plot(x,y, 'c',linewidth=3.3)
  32.     ax1.set_title('Pwnagestatistics')
  33.     ax1.set_xlabel('months_battling_evil')
  34.     ax1.set_ylabel('Enemies_Pwnd!!!!')
  35.     plt.show()
  36. graphex()
Advertisement
Add Comment
Please, Sign In to add comment