modusa 0.3.29__py3-none-any.whl → 0.3.31__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
@@ -27,7 +27,7 @@ def _calculate_extent(x, y):
27
27
  ]
28
28
 
29
29
  #======== 1D ===========
30
- def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, legend=None, show_grid=False):
30
+ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, legend=None, show_grid=False, show_stem=False):
31
31
  """
32
32
  Plots a 1D signal using matplotlib.
33
33
 
@@ -75,6 +75,9 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab
75
75
  show_grid: bool
76
76
  - If you want to show the grid.
77
77
  - Default: False
78
+ show_stem: bool:
79
+ - If you want stem plot.
80
+ - Default: False
78
81
 
79
82
  Returns
80
83
  -------
@@ -114,15 +117,40 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab
114
117
  y = signal[0]
115
118
  x = np.arange(y.size)
116
119
  if legend is not None:
117
- signal_ax.plot(x, y, label=legend[i])
120
+ if show_stem is True:
121
+ markerline, stemlines, baseline = signal_ax.stem(x, y, label=legend[i])
122
+ markerline.set_color(colors[i])
123
+ stemlines.set_color(colors[i])
124
+ baseline.set_color("k")
125
+ else:
126
+ signal_ax.plot(x, y, color=colors[i], label=legend[i])
118
127
  else:
119
- signal_ax.plot(x, y)
128
+ if show_stem is True:
129
+ markerline, stemlines, baseline = signal_ax.stem(x, y)
130
+ markerline.set_color(colors[i])
131
+ stemlines.set_color(colors[i])
132
+ baseline.set_color("k")
133
+ else:
134
+ signal_ax.plot(x, y, color=colors[i])
135
+
120
136
  elif len(signal) == 2:
121
137
  y, x = signal[0], signal[1]
122
138
  if legend is not None:
123
- signal_ax.plot(x, y, label=legend[i])
139
+ if show_stem is True:
140
+ markerline, stemlines, baseline = signal_ax.stem(x, y, label=legend[i])
141
+ markerline.set_color(colors[i])
142
+ stemlines.set_color(colors[i])
143
+ baseline.set_color("k")
144
+ else:
145
+ signal_ax.plot(x, y, color=colors[i], label=legend[i])
124
146
  else:
125
- signal_ax.plot(x, y)
147
+ if show_stem is True:
148
+ markerline, stemlines, baseline = signal_ax.stem(x, y, label=legend[i])
149
+ markerline.set_color(colors[i])
150
+ stemlines.set_color(colors[i])
151
+ baseline.set_color("k")
152
+ else:
153
+ signal_ax.plot(x, y, color=colors[i])
126
154
 
127
155
  # Add annotations
128
156
  if ann is not None:
@@ -166,7 +194,7 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab
166
194
  # Add legend
167
195
  if legend is not None:
168
196
  handles, labels = signal_ax.get_legend_handles_labels()
169
- fig.legend(handles, labels, loc='upper right', bbox_to_anchor=(0.9, 1.2), ncol=len(legend), frameon=False)
197
+ fig.legend(handles, labels, loc='upper right', bbox_to_anchor=(0.9, 1.2), ncol=len(legend), frameon=True)
170
198
 
171
199
  # Set title, labels
172
200
  if title is not None:
@@ -463,11 +491,11 @@ def plot_dist(*args, ann=None, xlim=None, ylim=None, ylabel=None, xlabel=None, t
463
491
  from scipy.stats import gaussian_kde
464
492
 
465
493
  if isinstance(legend, str):
466
- legend = (legend, )
494
+ legend = (legend, )
467
495
 
468
496
  if legend is not None:
469
- if len(legend) < len(args):
470
- raise ValueError(f"Legend should be provided for each signal.")
497
+ if len(legend) < len(args):
498
+ raise ValueError(f"Legend should be provided for each signal.")
471
499
 
472
500
  # Create figure
473
501
  fig = plt.figure(figsize=(16, 4))
@@ -480,28 +508,28 @@ def plot_dist(*args, ann=None, xlim=None, ylim=None, ylabel=None, xlabel=None, t
480
508
 
481
509
  # Set limits
482
510
  if xlim is not None:
483
- dist_ax.set_xlim(xlim)
511
+ dist_ax.set_xlim(xlim)
484
512
 
485
513
  if ylim is not None:
486
- dist_ax.set_ylim(ylim)
514
+ dist_ax.set_ylim(ylim)
487
515
 
488
516
  # Add plot
489
517
  for i, data in enumerate(args):
490
- # Fit gaussian to the data
491
- kde = gaussian_kde(data)
492
-
493
- # Create points to evaluate KDE
494
- x = np.linspace(min(data), max(data), npoints)
495
- y = kde(x)
496
-
497
- if legend is not None:
498
- dist_ax.plot(x, y, color=colors[i], label=legend[i])
499
- if show_hist is True:
500
- dist_ax.hist(data, bins=bins, density=True, alpha=0.3, facecolor=colors[i], edgecolor='black', label=legend[i])
501
- else:
502
- dist_ax.plot(x, y, color=colors[i])
503
- if show_hist is True:
504
- dist_ax.hist(data, bins=bins, density=True, alpha=0.3, facecolor=colors[i], edgecolor='black')
518
+ # Fit gaussian to the data
519
+ kde = gaussian_kde(data)
520
+
521
+ # Create points to evaluate KDE
522
+ x = np.linspace(np.min(data), np.max(data), npoints)
523
+ y = kde(x)
524
+
525
+ if legend is not None:
526
+ dist_ax.plot(x, y, color=colors[i], label=legend[i])
527
+ if show_hist is True:
528
+ dist_ax.hist(data, bins=bins, density=True, alpha=0.3, facecolor=colors[i], edgecolor='black', label=legend[i])
529
+ else:
530
+ dist_ax.plot(x, y, color=colors[i])
531
+ if show_hist is True:
532
+ dist_ax.hist(data, bins=bins, density=True, alpha=0.3, facecolor=colors[i], edgecolor='black')
505
533
 
506
534
  # Add annotations
507
535
  if ann is not None:
@@ -528,22 +556,22 @@ def plot_dist(*args, ann=None, xlim=None, ylim=None, ylabel=None, xlabel=None, t
528
556
 
529
557
  # Add legend
530
558
  if legend is not None:
531
- handles, labels = dist_ax.get_legend_handles_labels()
532
- fig.legend(handles, labels, loc='upper right', bbox_to_anchor=(0.9, 1.1), ncol=len(legend), frameon=True)
559
+ handles, labels = dist_ax.get_legend_handles_labels()
560
+ fig.legend(handles, labels, loc='upper right', bbox_to_anchor=(0.9, 1.1), ncol=len(legend), frameon=True)
533
561
 
534
562
  # Set title, labels
535
563
  if title is not None:
536
- annotation_ax.set_title(title, pad=10, size=11)
564
+ annotation_ax.set_title(title, pad=10, size=11)
537
565
  if xlabel is not None:
538
- dist_ax.set_xlabel(xlabel)
566
+ dist_ax.set_xlabel(xlabel)
539
567
  if ylabel is not None:
540
- dist_ax.set_ylabel(ylabel)
568
+ dist_ax.set_ylabel(ylabel)
541
569
 
542
570
  # Remove the boundaries and ticks from annotation axis
543
571
  if ann is not None:
544
- annotation_ax.tick_params(left=False, bottom=False, labelleft=False, labelbottom=False)
572
+ annotation_ax.tick_params(left=False, bottom=False, labelleft=False, labelbottom=False)
545
573
  else:
546
- annotation_ax.axis("off")
574
+ annotation_ax.axis("off")
547
575
 
548
576
  fig.subplots_adjust(hspace=0.01, wspace=0.05)
549
577
  plt.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: modusa
3
- Version: 0.3.29
3
+ Version: 0.3.31
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.29.dist-info/METADATA,sha256=vQcmNOAAZljrLUb7gHJoqvkTgSNsdzhzxxu0vcM5YJo,1369
2
- modusa-0.3.29.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
- modusa-0.3.29.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
4
- modusa-0.3.29.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
1
+ modusa-0.3.31.dist-info/METADATA,sha256=TqaRsl9ajARqimZirKDNdTahba3b9X_d0gJqD4oiSuc,1369
2
+ modusa-0.3.31.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
+ modusa-0.3.31.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
4
+ modusa-0.3.31.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=uq6kORFFAODiCMGmOLWO0shE8-dVFWf5gmV8wxekmnk,280
7
7
  modusa/config.py,sha256=bTqK4t00FZqERVITrxW_q284aDDJAa9aMSfFknfR-oU,280
@@ -47,7 +47,7 @@ modusa/tools/audio_loader.py,sha256=DrCzq0pdiQrUDIG-deLJGcu8EaylO5yRtwT4lr8WSf8,
47
47
  modusa/tools/audio_player.py,sha256=GP04TWW4jBwQBjANkfR_cJtEy7cIhvbu8RTwnf9hD6E,2817
48
48
  modusa/tools/base.py,sha256=C0ESJ0mIfjjRlAkRbSetNtMoOfS6IrHBjexRp3l_Mh4,1293
49
49
  modusa/tools/math_ops.py,sha256=ZZ7U4DgqT7cOeE7_Lzi_Qq-48WYfwR9_osbZwTmE9eg,8690
50
- modusa/tools/plotter.py,sha256=A559FRQcBCVfVKYBq90b-YyZjwGayTCf5Gsn1Zxc1k8,16674
50
+ modusa/tools/plotter.py,sha256=Sw_iy8OOZ2A_RQFnznQkRQMqgE_ucg6VlOWwMpi4QIY,17673
51
51
  modusa/tools/youtube_downloader.py,sha256=hB_X8-7nOHXOlxg6vv3wyhBLoAsWyomrULP6_uCQL7s,1698
52
52
  modusa/utils/.DS_Store,sha256=nLXMwF7QJNuglLI_Gk74F7vl5Dyus2Wd74Mgowijmdo,6148
53
53
  modusa/utils/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
@@ -56,4 +56,4 @@ modusa/utils/excp.py,sha256=L9vhaGjKpv9viJYdmC9n5ndmk2GVbUBuFyZyhAQZmWY,906
56
56
  modusa/utils/logger.py,sha256=K0rsnObeNKCxlNeSnVnJeRhgfmob6riB2uyU7h3dDmA,571
57
57
  modusa/utils/np_func_cat.py,sha256=TyIFgRc6bARRMDnZxlVURO5Z0I-GWhxRONYyIv-Vwxs,1007
58
58
  modusa/utils/plot.py,sha256=s_vNdxvKfwxEngvJPgrF1PcmxZNnNaaXPViHWjyjJ-c,5335
59
- modusa-0.3.29.dist-info/RECORD,,
59
+ modusa-0.3.31.dist-info/RECORD,,