add violin plots
python manage.py violins --module combo,wcs,authentic --datemin 2018-01-01 --events redmine
This commit is contained in:
parent
f467620f11
commit
fde8f61435
|
@ -0,0 +1,46 @@
|
|||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
from .common import GraphCommand
|
||||
|
||||
|
||||
import random
|
||||
import numpy as np
|
||||
|
||||
# Fixing random state for reproducibility
|
||||
np.random.seed(19680801)
|
||||
|
||||
|
||||
class Command(GraphCommand):
|
||||
|
||||
def handle(self, *args, **options):
|
||||
datetime_var = 'author_datetime'
|
||||
if options.get('committime'):
|
||||
datetime_var = 'commit_datetime'
|
||||
|
||||
data = []
|
||||
zones = []
|
||||
for i, (legend, serie) in enumerate(self.get_series(options)):
|
||||
zones.append(legend)
|
||||
events = []
|
||||
data.append(events)
|
||||
for event in serie:
|
||||
event_date = getattr(event, datetime_var)
|
||||
hour = event_date.hour
|
||||
if hour < 5:
|
||||
hour += 24
|
||||
minute = event_date.minute
|
||||
events.append(hour + minute / 60.0)
|
||||
|
||||
plt.figure()
|
||||
ax = plt.subplot()
|
||||
|
||||
plt.violinplot(data, widths=0.7,
|
||||
showmeans=True, showextrema=True, showmedians=True)
|
||||
|
||||
ax.set_xticks(range(1, len(zones)+1))
|
||||
ax.set_xticklabels(zones)
|
||||
ax.set_yticks(range(5, 29))
|
||||
ax.set_yticklabels(range(5, 24) + range(0, 5))
|
||||
|
||||
self.plot(options)
|
Reference in New Issue