Advertisement
Guest User

Untitled

a guest
Mar 24th, 2024
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. dates = np.load('dates.npy', allow_pickle=True)
  2. dates = dates.flatten()
  3.  
  4. print(type(dates))
  5. print(np.shape(dates))
  6.  
  7. l = []
  8. for i in range(len(dates)):
  9.     l.append(datetime.datetime.strptime(dates[i], '%Y-%m-%d %H:%M'))
  10.  
  11. print(type(l))
  12. print(type(l[0]))
  13. print(np.shape(l))
  14.  
  15. l = mdates.date2num(l)
  16.  
  17. ax = sns.boxenplot(l)
  18. ax.set(xlabel='MY X AXIS', ylabel='MY Y AXIS')
  19. ax.yaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M'))
  20. ax.yaxis.set_major_locator(mdates.YearLocator())
  21. plt.savefig('BOXENPLOT.pdf', bbox_inches='tight')
  22.  
  23. plt.hist(l, bins=10)
  24. axes = plt.gca()
  25. axes.set_xlabel('MY X AXIS')
  26. axes.set_ylabel('MY Y AXIS')
  27. axes.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m'))
  28. plt.gcf().autofmt_xdate()
  29. plt.show()
  30.  
  31. ax = sns.violinplot(l)
  32. ax.set(xlabel='MY X AXIS', ylabel='MY Y AXIS')
  33. ax.yaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M'))
  34. ax.yaxis.set_major_locator(mdates.YearLocator())
  35. plt.savefig('VIOLINPLOT.pdf', bbox_inches='tight')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement