modusa 0.3.62__py3-none-any.whl → 0.3.64__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 CHANGED
@@ -325,7 +325,7 @@ class Fig:
325
325
  else:
326
326
  curr_row[0].axvline(x=event, color=c, linestyle=ls, linewidth=lw)
327
327
 
328
- def add_annotation(self, ann, label=None, patterns=None, ax=None, ylim=(0, 1)):
328
+ def add_annotation(self, ann, label=None, patterns=None, ax=None, ylim=(0, 1), text_loc="middle"):
329
329
  """
330
330
  Add annotation to the figure.
331
331
 
@@ -348,6 +348,9 @@ class Fig:
348
348
  ylim: tuple[number, number]
349
349
  - Y-limit for the annotation.
350
350
  - Default: (0, 1)
351
+ text_loc: str
352
+ - Location of text relative to the box. (b for bottom, m for middle, t for top)
353
+ - Default: "middle"
351
354
  Returns
352
355
  -------
353
356
  None
@@ -373,6 +376,14 @@ class Fig:
373
376
 
374
377
  colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
375
378
 
379
+ # Text Location
380
+ if text_loc == "b":
381
+ text_yloc = ylim[0] + 0.1 * (ylim[1] - ylim[0])
382
+ elif text_loc == "t":
383
+ text_yloc = ylim[1] - 0.1 * (ylim[1] - ylim[0])
384
+ else:
385
+ text_yloc = (ylim[1] + ylim[0]) / 2
386
+
376
387
  for i, (start, end, tag, group) in enumerate(ann_copy):
377
388
  # We make sure that we only plot annotation that are within the x range of the current view
378
389
  if xlim is not None:
@@ -382,6 +393,7 @@ class Fig:
382
393
  # Clip boundaries to xlim
383
394
  start = max(start, xlim[0])
384
395
  end = min(end, xlim[1])
396
+
385
397
 
386
398
  if group is not None:
387
399
  box_color = colors[group]
@@ -393,7 +405,7 @@ class Fig:
393
405
  curr_row[0].add_patch(rect)
394
406
 
395
407
  text_obj = curr_row[0].text(
396
- (start + end) / 2, (ylim[1] - ylim[0]) / 2, tag,
408
+ (start + end) / 2, text_yloc, tag,
397
409
  ha='center', va='center',
398
410
  fontsize=10, color="black", fontweight='bold', zorder=10, clip_on=True
399
411
  )
@@ -410,7 +422,7 @@ class Fig:
410
422
  curr_row[0].add_patch(rect)
411
423
 
412
424
  text_obj = curr_row[0].text(
413
- (start + end) / 2, (ylim[1] - ylim[0]) / 2, tag,
425
+ (start + end) / 2, text_yloc, tag,
414
426
  ha='center', va='center',
415
427
  fontsize=10, color="black", fontweight='bold', zorder=10, clip_on=True
416
428
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: modusa
3
- Version: 0.3.62
3
+ Version: 0.3.64
4
4
  Summary: A modular signal analysis python library.
5
5
  Author-Email: Ankit Anand <ankit0.anand0@gmail.com>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
- modusa-0.3.62.dist-info/METADATA,sha256=ooCsjSQ_tkOBsvVnEoiuDj75jayR_MPXNsSYIJpDAy4,1436
2
- modusa-0.3.62.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
- modusa-0.3.62.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
4
- modusa-0.3.62.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
1
+ modusa-0.3.64.dist-info/METADATA,sha256=OqkcnVTdmTrYVNCmAXmWNyrKkpGW9jyGuvHwSGTaBWE,1436
2
+ modusa-0.3.64.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
+ modusa-0.3.64.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
4
+ modusa-0.3.64.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=GoYtQG1enLeK9WGeCPeFRenDgXWG1UZQFYkDk6j1RAA,18076
53
+ modusa/tools/plotter.py,sha256=ICbDGtZJIuWC_97x9THacZACnLEbVbAvx2PFXxL-vIU,18410
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.dist-info/RECORD,,
62
+ modusa-0.3.64.dist-info/RECORD,,