Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. import matplotlib.pyplot as plt
  4. import matplotlib.dates as dates
  5. from datetime import datetime, timedelta
  6.  
  7. x = []
  8. y = []
  9. with open("datasetDdos10Abril2017_unixtime_slowloris.csv") as f:
  10. for l in f:
  11. X,Y = l.split(",") #separador eh a virgula
  12. x.append(float(X))
  13. y.append(float (Y))
  14.  
  15. x1 = [datetime.fromtimestamp(int(d)) for d in x]
  16. y_pos = [idx for idx, i in enumerate(y)]
  17.  
  18. plt.gca().xaxis.set_major_formatter(dates.DateFormatter('%m/%d/%Y %H:%M:%S'))
  19.  
  20. y1 = []
  21. v = 0
  22. y_sorted = sorted(y)
  23. for i in y_sorted:
  24. if(abs(i-v > 50)):
  25. y1.append(i)
  26. v = i
  27.  
  28. plt.bar(y_pos, y, align='edge', color="blue", alpha=0.5, width=0.5) # <--- EDICAO PRINCIPAL
  29.  
  30. plt.title("Número de Conexões por segundo: Sem Ataques")
  31. plt.ylabel("Número de Conexões por segundo")
  32. plt.xlabel('Tempo')
  33. plt.xticks(y_pos, x1, size='small',rotation=35, ha="right")
  34. plt.yticks(y1)
  35. plt.ylim(ymin=y_sorted[0]-200) # valor minimo do eixo y
  36.  
  37. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement