forked from olgabot/prettyplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_eventplot.py
More file actions
28 lines (20 loc) · 761 Bytes
/
_eventplot.py
File metadata and controls
28 lines (20 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
__author__ = 'jgosmann'
from matplotlib.cbook import iterable
from prettyplotlib.utils import remove_chartjunk, maybe_get_ax
from prettyplotlib.colors import set2
def eventplot(*args, **kwargs):
ax, args, kwargs = maybe_get_ax(*args, **kwargs)
show_ticks = kwargs.pop('show_ticks', False)
alpha = kwargs.pop('alpha', 1.0)
if len(args) > 0:
positions = args[0]
else:
positions = kwargs['positions']
if any(iterable(p) for p in positions):
size = len(positions)
else:
size = 1
kwargs.setdefault('colors', [c + (alpha,) for c in set2[:size]])
event_collections = ax.eventplot(*args, **kwargs)
remove_chartjunk(ax, ['top', 'right'], show_ticks=show_ticks)
return event_collections