Advertisement
FriterAAAAAAAA

Untitled

Oct 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.70 KB | None | 0 0
  1. import datetime as dt
  2. import matplotlib.pyplot as plt
  3. import matplotlib.font_manager as font_manager
  4. import matplotlib.dates as dates
  5. from matplotlib.dates import WEEKLY, MONTHLY, DateFormatter, rrulewrapper, RRuleLocator
  6. import numpy as np
  7. from tkinter import *
  8.  
  9. def create_date(date):
  10.     d, m, y = [int(s) for s in date.split('-')]
  11.     return dates.date2num(dt.datetime(y, m, d))
  12.  
  13. def create_diagramm_gantt(event):
  14.     name_characters, custom_dates = [],[]
  15.     for people in characters: name_characters.append(people["Name"]); custom_dates.append([create_date(people["Begin_date"]),create_date(people["End_date"])])
  16.     number_characters = len(name_characters)
  17.     position, date_of_task = np.arange(0.5,number_characters*0.5+0.5,0.5),{}
  18.     for i, name in enumerate(name_characters): date_of_task[name] = custom_dates[i]
  19.     figure = plt.figure(figsize=(20,8))
  20.     ax = figure.add_subplot(111)
  21.     for i in range(number_characters):
  22.         start_date,end_date = date_of_task[name_characters[i]]
  23.         ax.barh((i*0.5)+0.5, end_date - start_date, left=start_date, height=0.3, align='center', edgecolor='lightgreen', color='lightgreen', alpha = 0.8)
  24.     _, labelsy = plt.yticks(position,name_characters)
  25.     plt.setp(labelsy, fontsize = 14)
  26.     ax.set_ylim(ymin = -0.1, ymax = number_characters*0.5+0.5)
  27.     ax.grid(color = 'g', linestyle = ':')
  28.     ax.xaxis_date()
  29.     location = RRuleLocator(rrulewrapper(WEEKLY, interval=1))
  30.     formatter = DateFormatter("%d-%b '%y")
  31.     ax.xaxis.set_major_locator(location)
  32.     ax.xaxis.set_major_formatter(formatter)
  33.     plt.setp(ax.get_xticklabels(), rotation=30, fontsize=10)
  34.     font = font_manager.FontProperties(size='small')
  35. https://pastebin.com/BQtrqNkn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement