Skip to content

Commit

Permalink
initial counter plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
knarrff committed Mar 11, 2024
1 parent f69aba9 commit 64f76f3
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions matrixcounter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"rooms": {"!OLvpfIdNTaXjccGSnY:matrix.org": {"name": "deRSE-jobs", "counts": [["2024-03-05T00:16:27", "2024-03-05T09:00:02", "2024-03-05T10:00:01", "2024-03-05T11:00:02", "2024-03-05T13:00:02", "2024-03-05T14:00:02", "2024-03-05T15:00:01", "2024-03-05T16:00:02", "2024-03-05T17:00:03", "2024-03-05T18:00:02", "2024-03-06T18:00:02", "2024-03-06T19:00:01", "2024-03-07T11:00:02", "2024-03-07T12:00:02", "2024-03-07T19:00:01", "2024-03-07T20:00:01", "2024-03-08T09:00:01", "2024-03-08T10:00:06", "2024-03-08T22:38:20"], [13, 13, 14, 15, 15, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25]]}, "!kcuCWEiKDBYXwGQwFD:matrix.org": {"name": "deRSE-test", "counts": [["2024-03-05T00:16:27", "2024-03-08T22:38:20"], [1, 1]]}, "!jhzhFqWmuEUZddCYsk:matrix.org": {"name": "deRSE-offtopic", "counts": [["2024-03-05T00:16:27", "2024-03-05T09:00:02", "2024-03-05T10:00:01", "2024-03-05T13:00:02", "2024-03-05T14:00:02", "2024-03-05T15:00:01", "2024-03-05T16:00:02", "2024-03-05T17:00:03", "2024-03-05T18:00:02", "2024-03-05T19:00:02", "2024-03-06T11:00:02", "2024-03-06T12:00:05", "2024-03-07T11:00:02", "2024-03-07T12:00:02", "2024-03-07T18:00:02", "2024-03-07T19:00:01", "2024-03-08T09:00:01", "2024-03-08T10:00:06", "2024-03-08T16:00:02", "2024-03-08T17:00:02", "2024-03-08T22:38:20"], [12, 12, 13, 13, 17, 18, 20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27]]}, "!EDyLVFagIyDJGvQIPK:matrix.org": {"name": "deRSE", "counts": [["2024-03-05T00:16:27", "2024-03-05T08:00:02", "2024-03-05T09:00:02", "2024-03-05T10:00:01", "2024-03-05T11:00:02", "2024-03-05T13:00:02", "2024-03-05T14:00:02", "2024-03-05T16:00:02", "2024-03-05T17:00:03", "2024-03-05T18:00:02", "2024-03-06T01:00:01", "2024-03-06T02:00:06", "2024-03-06T10:00:02", "2024-03-06T11:00:02", "2024-03-06T12:00:05", "2024-03-07T11:00:02", "2024-03-07T12:00:02", "2024-03-07T13:00:01", "2024-03-07T14:00:02", "2024-03-07T15:00:02", "2024-03-07T19:00:01", "2024-03-07T20:00:01", "2024-03-08T09:00:01", "2024-03-08T10:00:06", "2024-03-08T14:00:01", "2024-03-08T15:00:02", "2024-03-08T16:00:02", "2024-03-08T17:00:02", "2024-03-08T22:38:20"], [21, 21, 22, 23, 24, 24, 43, 43, 44, 45, 45, 46, 46, 47, 48, 48, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56]]}, "!LKxMPbhEZEndXVoxLi:matrix.org": {"name": "deRSE-general", "counts": [["2024-03-05T00:16:27", "2024-03-05T08:00:02", "2024-03-05T09:00:02", "2024-03-05T10:00:01", "2024-03-05T11:00:02", "2024-03-05T13:00:02", "2024-03-05T14:00:02", "2024-03-05T15:00:01", "2024-03-05T16:00:02", "2024-03-05T17:00:03", "2024-03-05T18:00:02", "2024-03-06T01:00:01", "2024-03-06T02:00:06", "2024-03-06T06:00:01", "2024-03-06T07:00:01", "2024-03-06T10:00:02", "2024-03-06T11:00:02", "2024-03-07T11:00:02", "2024-03-07T12:00:02", "2024-03-07T13:00:01", "2024-03-07T19:00:01", "2024-03-07T20:00:01", "2024-03-08T09:00:01", "2024-03-08T10:00:06", "2024-03-08T14:00:01", "2024-03-08T15:00:02", "2024-03-08T16:00:02", "2024-03-08T17:00:02", "2024-03-08T22:38:20"], [17, 17, 18, 19, 21, 21, 39, 39, 40, 41, 42, 42, 43, 43, 44, 44, 45, 45, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52]]}, "!JDKijksgmdsXEBLxDw:matrix.org": {"name": "de-RSE-alt", "counts": [["2024-03-05T00:16:27", "2024-03-08T22:38:20"], [3, 3]]}, "!VxJECxBCHRNToWZOke:matrix.org": {"name": "deRSE-events", "counts": [["2024-03-05T00:16:27", "2024-03-05T09:00:02", "2024-03-05T10:00:01", "2024-03-05T11:00:02", "2024-03-05T12:00:01", "2024-03-05T13:00:02", "2024-03-05T14:00:02", "2024-03-05T15:00:01", "2024-03-05T16:00:02", "2024-03-05T17:00:03", "2024-03-05T18:00:02", "2024-03-06T08:00:02", "2024-03-06T09:00:01", "2024-03-06T11:00:02", "2024-03-06T12:00:05", "2024-03-06T14:00:03", "2024-03-06T15:00:01", "2024-03-07T11:00:02", "2024-03-07T12:00:02", "2024-03-07T13:00:01", "2024-03-07T18:00:02", "2024-03-07T19:00:01", "2024-03-08T09:00:01", "2024-03-08T10:00:06", "2024-03-08T22:38:20"], [13, 13, 14, 14, 15, 15, 19, 20, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 28, 29, 29, 30, 30, 31, 31]]}, "!vQGROCWyxsaEhbgwiA:matrix.org": {"name": "deRSE-deRSE24", "counts": [["2024-03-05T00:16:27", "2024-03-05T09:00:02", "2024-03-05T10:00:01", "2024-03-05T11:00:02", "2024-03-05T13:00:02", "2024-03-05T14:00:02", "2024-03-05T15:00:01", "2024-03-05T16:00:02", "2024-03-05T17:00:03", "2024-03-05T18:00:02", "2024-03-06T16:00:01", "2024-03-06T17:00:02", "2024-03-07T19:00:01", "2024-03-07T20:00:01", "2024-03-08T08:00:02", "2024-03-08T09:00:01", "2024-03-08T22:38:20"], [4, 4, 5, 6, 6, 8, 10, 10, 11, 12, 12, 13, 13, 14, 14, 15, 15]]}, "!xpcVawtyqZsPgeIMaY:uni-jena.de": {"name": "deRSE-test2", "counts": [["2024-03-05T00:16:27", "2024-03-06T22:00:03", "2024-03-06T23:00:02", "2024-03-08T22:38:20"], [1, 1, 0, 0]]}, "!QhHoxbttoUtWEumEJp:matrix.org": {"name": "deRSE-moderators", "counts": [["2024-03-05T00:16:27", "2024-03-08T22:38:20"], [4, 4]]}, "!ZrMXbVuXKqhhZeAuqZ:matrix.org": {"name": "deRSE-alt-off-topic", "counts": [["2024-03-05T00:16:27", "2024-03-08T22:38:20"], [2, 2]]}, "!DIuKfCjWsmDKkzaeiA:matrix.org": {"name": "deRSE-alt-general", "counts": [["2024-03-05T00:16:27", "2024-03-06T11:00:02", "2024-03-06T12:00:05", "2024-03-08T22:38:20"], [3, 3, 2, 2]]}, "!dCBtfgnyRbeQilNuNu:matrix.org": {"name": "deRSE-introductions", "counts": [["2024-03-05T00:16:27", "2024-03-05T08:00:02", "2024-03-05T09:00:02", "2024-03-05T10:00:01", "2024-03-05T11:00:02", "2024-03-05T12:00:01", "2024-03-05T13:00:02", "2024-03-05T14:00:02", "2024-03-05T15:00:01", "2024-03-05T16:00:02", "2024-03-05T17:00:03", "2024-03-06T01:00:01", "2024-03-06T02:00:06", "2024-03-06T10:00:02", "2024-03-06T11:00:02", "2024-03-06T12:00:05", "2024-03-07T09:00:02", "2024-03-07T10:00:02", "2024-03-07T11:00:02", "2024-03-07T12:00:02", "2024-03-07T19:00:01", "2024-03-07T20:00:01", "2024-03-08T09:00:01", "2024-03-08T10:00:06", "2024-03-08T14:00:01", "2024-03-08T15:00:02", "2024-03-08T16:00:02", "2024-03-08T17:00:02", "2024-03-08T22:38:20"], [15, 15, 16, 17, 18, 18, 19, 36, 36, 37, 38, 38, 39, 39, 40, 41, 41, 42, 42, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48]]}, "!usvxVdRRMMQhYGffDO:matrix.org": {"name": "deRSE-Open Science", "counts": [["2024-03-05T00:16:27", "2024-03-05T10:00:01", "2024-03-05T11:00:02", "2024-03-05T13:00:02", "2024-03-05T14:00:02", "2024-03-05T15:00:01", "2024-03-06T09:00:01", "2024-03-06T10:00:02", "2024-03-07T11:00:02", "2024-03-07T12:00:02", "2024-03-08T11:00:01", "2024-03-08T12:00:01", "2024-03-08T22:38:20"], [1, 1, 2, 2, 4, 6, 6, 7, 7, 8, 8, 9, 9]]}, "total": {"name": "Total", "counts": [["2024-03-05T00:16:27", "2024-03-05T08:00:02", "2024-03-05T09:00:02", "2024-03-05T10:00:01", "2024-03-05T11:00:02", "2024-03-05T13:00:02", "2024-03-05T14:00:02", "2024-03-05T16:00:02", "2024-03-05T17:00:03", "2024-03-05T18:00:02", "2024-03-06T01:00:01", "2024-03-06T02:00:06", "2024-03-06T10:00:02", "2024-03-06T11:00:02", "2024-03-06T12:00:05", "2024-03-07T11:00:02", "2024-03-07T12:00:02", "2024-03-07T13:00:01", "2024-03-07T14:00:02", "2024-03-07T15:00:02", "2024-03-07T19:00:01", "2024-03-07T20:00:01", "2024-03-08T09:00:01", "2024-03-08T10:00:06", "2024-03-08T14:00:01", "2024-03-08T15:00:02", "2024-03-08T16:00:02", "2024-03-08T17:00:02", "2024-03-08T22:38:20"], [22, 22, 23, 24, 25, 25, 44, 44, 45, 46, 46, 47, 47, 48, 49, 49, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57]]}, "!NYHepJfaPBuohmLrLK:matrix.org": {"name": "deRSE-conference-2025-orga", "counts": [["2024-03-06T11:00:02", "2024-03-06T12:00:05", "2024-03-08T22:38:20"], [2, 3, 3]]}, "!bvhVgASkBhRlMkVYyv:matrix.org": {"name": "deRSE-chapters", "counts": [["2024-03-07T19:00:01", "2024-03-07T20:00:01", "2024-03-08T07:00:02", "2024-03-08T08:00:02", "2024-03-08T09:00:01", "2024-03-08T10:00:06", "2024-03-08T11:00:01", "2024-03-08T12:00:01", "2024-03-08T22:38:20"], [0, 2, 2, 3, 3, 4, 7, 8, 8]]}, "!lZujBGXDgDRaWczzgJ:matrix.org": {"name": "deRSE-Leibniz", "counts": [["2024-03-07T20:00:01", "2024-03-08T22:38:20"], [2, 2]]}, "!FlkCaRwCJMAyLtCicx:matrix.org": {"name": "deRSE-AK-NFDI", "counts": [["2024-03-07T20:00:01", "2024-03-08T22:38:20"], [4, 4]]}}}
72 changes: 72 additions & 0 deletions plot_counter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
import sys, os
from pprint import pprint
import argparse
import json
from datetime import datetime
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
import matplotlib.dates as mdates

parser = argparse.ArgumentParser(description="")
parser.add_argument('file',
help='input json file to use')
parser.add_argument('-o', '--output',
help='output file to write the figure to; extension defines format to the'
'extend matplotlib supports')
args = vars(parser.parse_args())

try:
fd = open(args['file'])
except:
print(f'cannot open {args["file"]}')
sys.exit(1)
try:
data = json.loads(fd.read())
except:
print(f'cannot read data in {args["file"]}')
sys.exit(1)

scaling = .6
fig = plt.figure(figsize=(16*scaling, 9*scaling))
ax = fig.subplots()

xmin=datetime.fromisoformat('2999-01-01T00:00:00')
xmax=datetime.fromisoformat('1999-01-01T00:00:00')

for room, roomdata in sorted(data['rooms'].items(), key=lambda x: x[1]['counts'][1][-1]):
if roomdata['name'].startswith('deRSE-test'):
continue
if roomdata['name'].startswith('deRSE-alt'):
continue
if roomdata['name'].startswith('de-RSE-alt'):
continue
times = [datetime.fromisoformat(s) for s in roomdata['counts'][0]]
counts = roomdata['counts'][1]
times.append(times[-1])
xmin = min(xmin, times[0])
xmax = max(xmax, times[-1])

ax.stairs(counts, edges=times, lw=2, label=roomdata['name'])

ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(False)

ax.set_xlim(xmin=xmin, xmax=xmax)
ax.set_ylim(ymin=0)
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
for label in ax.get_xticklabels(which='major'):
label.set(rotation=20, horizontalalignment='right')
ax.yaxis.tick_right()
ax.yaxis.set_major_locator(MaxNLocator(integer=True))

handles, labels = ax.get_legend_handles_labels()
ax.legend(reversed(handles), reversed(labels),
loc='center left', bbox_to_anchor=(1.1, 0.5), frameon=False)

plt.tight_layout()
outfilename = 'counter_matrix.pdf'
if args['output']:
outfilename = args['output']
plt.savefig(outfilename)

0 comments on commit 64f76f3

Please sign in to comment.