modusa 0.3.56__py3-none-any.whl → 0.3.58__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- modusa/tools/plotter.py +32 -8
- {modusa-0.3.56.dist-info → modusa-0.3.58.dist-info}/METADATA +1 -1
- {modusa-0.3.56.dist-info → modusa-0.3.58.dist-info}/RECORD +6 -6
- {modusa-0.3.56.dist-info → modusa-0.3.58.dist-info}/WHEEL +0 -0
- {modusa-0.3.56.dist-info → modusa-0.3.58.dist-info}/entry_points.txt +0 -0
- {modusa-0.3.56.dist-info → modusa-0.3.58.dist-info}/licenses/LICENSE.md +0 -0
modusa/tools/plotter.py
CHANGED
|
@@ -12,8 +12,8 @@ import matplotlib.font_manager as fm
|
|
|
12
12
|
import matplotlib.pyplot as plt
|
|
13
13
|
import matplotlib.gridspec as gridspec
|
|
14
14
|
from matplotlib.patches import Rectangle
|
|
15
|
-
|
|
16
15
|
import numpy as np
|
|
16
|
+
import fnmatch
|
|
17
17
|
|
|
18
18
|
#===== Loading Devanagari font ========
|
|
19
19
|
def _load_devanagari_font():
|
|
@@ -259,7 +259,6 @@ class Fig:
|
|
|
259
259
|
curr_row = self._get_curr_row() if ax is None else self._axs[ax]
|
|
260
260
|
|
|
261
261
|
extent = self._calculate_extent(x, y, o)
|
|
262
|
-
print(extent)
|
|
263
262
|
|
|
264
263
|
im = curr_row[0].imshow(M, aspect="auto", origin=o, cmap=c, extent=extent)
|
|
265
264
|
|
|
@@ -326,7 +325,7 @@ class Fig:
|
|
|
326
325
|
else:
|
|
327
326
|
curr_row[0].axvline(x=event, color=c, linestyle=ls, linewidth=lw)
|
|
328
327
|
|
|
329
|
-
def add_annotation(self, ann, label=None, ax=None):
|
|
328
|
+
def add_annotation(self, ann, label=None, patterns=None, ax=None):
|
|
330
329
|
"""
|
|
331
330
|
Add annotation to the figure.
|
|
332
331
|
|
|
@@ -339,6 +338,10 @@ class Fig:
|
|
|
339
338
|
- Label for the annotation type.
|
|
340
339
|
- This will appear to the right of the aux plot.
|
|
341
340
|
- Default: None
|
|
341
|
+
patterns: list[str]
|
|
342
|
+
- Patterns to group annotations
|
|
343
|
+
- E.g., "*R" or "<tag>*" or ["A*", "*B"]
|
|
344
|
+
- All elements in a group will have same color.
|
|
342
345
|
ax: int
|
|
343
346
|
- Which specific axis to plot (1, 2, 3, ...)
|
|
344
347
|
- None
|
|
@@ -350,7 +353,24 @@ class Fig:
|
|
|
350
353
|
|
|
351
354
|
xlim = self._xlim
|
|
352
355
|
|
|
353
|
-
|
|
356
|
+
if isinstance(patterns, str): patterns = [patterns]
|
|
357
|
+
|
|
358
|
+
if patterns is not None:
|
|
359
|
+
for i, (start, end, tag) in enumerate(ann):
|
|
360
|
+
for j, pattern in enumerate(patterns):
|
|
361
|
+
if fnmatch.fnmatch(tag, pattern):
|
|
362
|
+
ann[i] = (start, end, tag, j)
|
|
363
|
+
break
|
|
364
|
+
else:
|
|
365
|
+
ann[i] = (start, end, tag, None)
|
|
366
|
+
else:
|
|
367
|
+
for i, (start, end, tag) in enumerate(ann):
|
|
368
|
+
ann[i] = (start, end, tag, None)
|
|
369
|
+
|
|
370
|
+
colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
|
|
371
|
+
print(ann)
|
|
372
|
+
|
|
373
|
+
for i, (start, end, tag, group) in enumerate(ann):
|
|
354
374
|
# We make sure that we only plot annotation that are within the x range of the current view
|
|
355
375
|
if xlim is not None:
|
|
356
376
|
if start >= xlim[1] or end <= xlim[0]:
|
|
@@ -360,8 +380,10 @@ class Fig:
|
|
|
360
380
|
start = max(start, xlim[0])
|
|
361
381
|
end = min(end, xlim[1])
|
|
362
382
|
|
|
363
|
-
|
|
364
|
-
|
|
383
|
+
if group is not None:
|
|
384
|
+
box_color = colors[group]
|
|
385
|
+
else:
|
|
386
|
+
box_color = "lightgray"
|
|
365
387
|
|
|
366
388
|
width = end - start
|
|
367
389
|
rect = Rectangle((start, 0), width, 1, facecolor=box_color, edgecolor="black", alpha=0.7)
|
|
@@ -375,8 +397,10 @@ class Fig:
|
|
|
375
397
|
|
|
376
398
|
text_obj.set_clip_path(rect)
|
|
377
399
|
else:
|
|
378
|
-
|
|
379
|
-
|
|
400
|
+
if group is not None:
|
|
401
|
+
box_color = colors[group]
|
|
402
|
+
else:
|
|
403
|
+
box_color = "lightgray"
|
|
380
404
|
|
|
381
405
|
width = end - start
|
|
382
406
|
rect = Rectangle((start, 0), width, 1, facecolor=box_color, edgecolor="black", alpha=0.7)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
modusa-0.3.
|
|
2
|
-
modusa-0.3.
|
|
3
|
-
modusa-0.3.
|
|
4
|
-
modusa-0.3.
|
|
1
|
+
modusa-0.3.58.dist-info/METADATA,sha256=aMaG5ln4Uq8f-llp978sCAUA7sU9ZlgB5DTrR7YzyEk,1436
|
|
2
|
+
modusa-0.3.58.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
|
|
3
|
+
modusa-0.3.58.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
|
|
4
|
+
modusa-0.3.58.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
|
|
5
5
|
modusa/.DS_Store,sha256=_gm6qJREwfMi8dE7n5S89_RG46u5t3xHyD-smNhtNoM,6148
|
|
6
6
|
modusa/__init__.py,sha256=RMIKAZZ27w1oh2UFMJvZQtQ-SluIQsac_3mSK_LaM30,277
|
|
7
7
|
modusa/config.py,sha256=bTqK4t00FZqERVITrxW_q284aDDJAa9aMSfFknfR-oU,280
|
|
@@ -50,7 +50,7 @@ modusa/tools/audio_player.py,sha256=GP04TWW4jBwQBjANkfR_cJtEy7cIhvbu8RTwnf9hD6E,
|
|
|
50
50
|
modusa/tools/audio_recorder.py,sha256=d2fVt0Sd2tlBdb2WlUs60K4N23zuxM3KUpQqX0ifPi8,2769
|
|
51
51
|
modusa/tools/base.py,sha256=C0ESJ0mIfjjRlAkRbSetNtMoOfS6IrHBjexRp3l_Mh4,1293
|
|
52
52
|
modusa/tools/math_ops.py,sha256=ZZ7U4DgqT7cOeE7_Lzi_Qq-48WYfwR9_osbZwTmE9eg,8690
|
|
53
|
-
modusa/tools/plotter.py,sha256=
|
|
53
|
+
modusa/tools/plotter.py,sha256=gxAqWAoXTsXXoA8uRV5KtjZbbCxeMTxLztMuoywAJxc,17874
|
|
54
54
|
modusa/tools/youtube_downloader.py,sha256=hB_X8-7nOHXOlxg6vv3wyhBLoAsWyomrULP6_uCQL7s,1698
|
|
55
55
|
modusa/utils/.DS_Store,sha256=nLXMwF7QJNuglLI_Gk74F7vl5Dyus2Wd74Mgowijmdo,6148
|
|
56
56
|
modusa/utils/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
|
|
@@ -59,4 +59,4 @@ modusa/utils/excp.py,sha256=L9vhaGjKpv9viJYdmC9n5ndmk2GVbUBuFyZyhAQZmWY,906
|
|
|
59
59
|
modusa/utils/logger.py,sha256=K0rsnObeNKCxlNeSnVnJeRhgfmob6riB2uyU7h3dDmA,571
|
|
60
60
|
modusa/utils/np_func_cat.py,sha256=TyIFgRc6bARRMDnZxlVURO5Z0I-GWhxRONYyIv-Vwxs,1007
|
|
61
61
|
modusa/utils/plot.py,sha256=s_vNdxvKfwxEngvJPgrF1PcmxZNnNaaXPViHWjyjJ-c,5335
|
|
62
|
-
modusa-0.3.
|
|
62
|
+
modusa-0.3.58.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|