Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.84 KB | None | 0 0
  1. import os                                                                          
  2. import sys                                                                          
  3. import numpy as np                                                                  
  4. import matplotlib.pyplot as plt                                                    
  5. from matplotlib.dates import DayLocator, HourLocator, DateFormatter, drange        
  6. import datetime as dt                                                              
  7.                                                                                    
  8. ff = "temp-25c.txt"                                                                
  9. fn = open(ff, "r")                                                                  
  10. tt = np.array([])                                                                  
  11. d1 = np.array([])                                                                  
  12. d2 = np.array([])                                                                  
  13. d3 = np.array([])                                                                  
  14. d4 = np.array([])                                                                  
  15. for i in fn.readlines()[4:]:                                                        
  16.     i = i.split()                                                                  
  17.     j = [int(ii) for ii in i[0].split('-')]                                        
  18.     k = [int(ii) for ii in i[1].split(':')]                                        
  19.     a = dt.datetime(j[2], j[0], j[1], k[0], k[1], k[2])                            
  20.     tt = np.append(tt, a)                                                          
  21.     d1 = np.append(d1, int(i[4]))                                                  
  22.     d2 = np.append(d2, int(i[4]))                                                  
  23.     d3 = np.append(d3, int(i[4]))                                                  
  24.     d4 = np.append(d4, int(i[4]))                                                  
  25.                                                                                    
  26. ax = plt.subplot(111)                                                              
  27. ax.plot_date(tt, d1)                                                                
  28. ax.plot_date(tt, d2)                                                                
  29. ax.plot_date(tt, d3)                                                                
  30. ax.plot_date(tt, d4)                                                                
  31. plt.setp( ax.xaxis.get_majorticklabels(), rotation=70, horizontalalignment='right' )
  32. plt.tight_layout(                                                                  
  33. plt.savefig("res.png")                                                              
  34. ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement