Szala

axis to graph

Sep 4th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. #cat file.txt | sed -e 's/,//g' -e 's/(//g' -e 's/)//g' > bar.txt
  2.  
  3. f = open('bar.txt')
  4. adat = []
  5. for line in f.readlines():
  6.         y = [value for value in line.split()]
  7.         adat.append( y )
  8. f.close
  9. #print adat
  10. from pylab import *  # Matplotlib
  11.  
  12. def main():
  13.     # sequence of data points to graph (x, y coordinates)
  14.     points = adat
  15.     graph(points)
  16.  
  17.  
  18. def graph(points):
  19.     fig = figure(figsize=(100, 20))  # image dimensions  
  20.     ax = fig.add_subplot(111)
  21.     ax.grid(True, color='#666666')
  22.     xticks(size='x-small')
  23.     yticks(size='x-small')
  24.     x_seq = [item[0] for item in points]
  25.     y_seq = [item[1] for item in points]
  26.     ax.plot(x_seq, y_seq,
  27.         color='blue', linestyle='-', linewidth=1.0, marker='o',
  28.         markeredgecolor='blue', markerfacecolor='yellow', markersize=2.0)
  29.     savefig('graph.png')
  30.  
  31.  
  32. if __name__ == '__main__':
  33.     main()
Advertisement
Add Comment
Please, Sign In to add comment