Advertisement
berl0ga

графики

Sep 16th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.68 KB | None | 0 0
  1. from collections import OrderedDict
  2.  
  3. import matplotlib.pyplot as plt
  4.  
  5. deps = {'3': 30, '4': 129, '1': 91, '2': 205, '5': 142}
  6. courses = {'3': 125, '4': 103, '1': 206, '1M': 13, '5': 12, '2M': 23, '2': 152}
  7. groups = Counter({'474': 17, '276': 14, '475': 13, '265': 13, '278': 11, '174': 11, '571': 11, '144': 11, '173': 10, '574': 10, '446': 10, '277': 10, '461': 10, '554': 9, '253': 9, '243': 9, '273': 8, '465': 8, '469м': 8, '476': 8, '175': 8, '264': 7, '551': 7, '464': 7, '254': 7, '363': 7, '552': 7, '251': 7, '270': 6, '550': 6, '546': 6, '272': 6, '454': 6, '572': 6, '165': 6, '263': 6, '444': 5, '255': 5, '576': 5, '172': 5, '471': 5, '252': 5, '553': 5, '563': 5, '462': 5, '560': 5, '274': 5, '361': 5, '152': 4, '573': 4, '564': 4, '268': 4, '244': 4, '242': 4, '555': 4, '271м': 4, '5364': 4, '141': 4, '249': 4, '455': 4, '2566': 4, '532': 4, '472': 4, '441': 4, '545': 4, '452': 4, '2548': 4, '561': 4, '267': 4, '163': 4, '445': 3, '267м': 3, '266': 3, '171': 3, '543': 3, '570': 3, '161': 3, '544': 3, '565': 3, '351': 3, '246': 3, '261': 3, '143': 3, '247': 3, '245': 3, '456': 3, '154': 3, '562': 3, '258': 3, '266м': 2, '575': 2, '262': 2, '164': 2, '541': 2, '372': 2, '275': 2, '241': 2, '371': 2, '248': 2, '342': 2, '257': 2, '153': 2, '256': 2, '142': 2, '558': 2, '568': 2, '271': 2, '151': 2, '531(хтвмс)': 2, '362': 2, '540': 2, '1612м': 1, '4711м': 1, '145': 1, '179м(хнимэт)': 1, '178м': 1, '4710м': 1, '375м': 1, '374м': 1, '167м': 1, '442': 1, '542': 1, '272м': 1, '2547': 1, '367м': 1, '466': 1, '268м': 1, '162': 1, '043221': 1, '341': 1, '355': 1, '264м': 1, '261м': 1, '2556': 1, '352': 1, '179м(тэп)': 1, '467м': 1, '263м': 1, '373м': 1, '533': 1, '530': 1, '569м': 1, '559': 1, '2557': 1, '166м': 1})
  8. most_common_groups = {k: v for k, v in groups.most_common(20)}
  9. notifications = {'Не подписан': 410, '20:00': 49, '21:00': 38, '8:00': 31, '22:00': 28, '7:30': 19, '7:00': 16, '23:00': 9}
  10.  
  11. f = plt.figure(1)
  12. f.set_figheight(16)
  13. f.set_figwidth(20)
  14. plt.style.use('ggplot')
  15.  
  16. def bar_plot(d, title):
  17.     data = OrderedDict(sorted(d.items(), key=lambda x: -x[1]))
  18.     y = range(len(data))
  19.     bars = data.values()
  20.     plt.bar(y, bars, align='center', alpha=0.5)
  21.     plt.xticks(y, data.keys())
  22.     plt.ylabel('пользователи')
  23.     plt.title(title)
  24.    
  25. plt.subplot(221)
  26. bar_plot(deps, 'Распределение по факультетам')
  27. plt.subplot(222)
  28. bar_plot(courses, 'Распределение по курсам')
  29. plt.subplot(223)
  30. bar_plot(most_common_groups, 'Распределение по группам')
  31. plt.subplot(224)
  32. bar_plot(notifications, 'Подписки на уведомления')
  33.  
  34. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement