modusa 0.3.4.dev1__py3-none-any.whl → 0.3.4.dev2__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, show_stem=False):
30
+ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, legend=None, fmt=None, show_grid=False, show_stem=False):
31
31
  """
32
32
  Plots a 1D signal using matplotlib.
33
33
 
@@ -72,6 +72,9 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab
72
72
  legend : list[str] | None
73
73
  - List of legend labels corresponding to each signal if plotting multiple lines.
74
74
  - Default: None
75
+ fmt: list[str] | None
76
+ - linefmt for different line plots.
77
+ - Default: None
75
78
  show_grid: bool
76
79
  - If you want to show the grid.
77
80
  - Default: False
@@ -90,15 +93,19 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab
90
93
  raise ValueError(f"1D signal needs to have max 2 arrays (y, x) or simply (y, )")
91
94
 
92
95
  if isinstance(legend, str): legend = (legend, )
93
-
94
96
  if legend is not None:
95
97
  if len(legend) < len(args):
96
- raise ValueError(f"Legend should be provided for each signal.")
98
+ raise ValueError(f"`legend` should be provided for each signal.")
99
+
100
+ if isinstance(fmt, str): fmt = [fmt]
101
+ if fmt is not None:
102
+ if len(fmt) < len(args):
103
+ raise ValueError(f"`fmt` should be provided for each signal.")
104
+
105
+ colors = plt.get_cmap('tab10').colors
97
106
 
98
107
  fig = plt.figure(figsize=(16, 2))
99
108
  gs = gridspec.GridSpec(2, 1, height_ratios=[0.2, 1])
100
-
101
- colors = plt.get_cmap('tab10').colors
102
109
 
103
110
  signal_ax = fig.add_subplot(gs[1, 0])
104
111
  annotation_ax = fig.add_subplot(gs[0, 0], sharex=signal_ax)
@@ -109,7 +116,6 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab
109
116
 
110
117
  if ylim is not None:
111
118
  signal_ax.set_ylim(ylim)
112
-
113
119
 
114
120
  # Add signal plot
115
121
  for i, signal in enumerate(args):
@@ -123,7 +129,10 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab
123
129
  stemlines.set_color(colors[i])
124
130
  baseline.set_color("k")
125
131
  else:
126
- signal_ax.plot(x, y, color=colors[i], label=legend[i])
132
+ if fmt is not None:
133
+ signal_ax.plot(x, y, fmt[i], markersize=4, label=legend[i])
134
+ else:
135
+ signal_ax.plot(x, y, color=colors[i], label=legend[i])
127
136
  else:
128
137
  if show_stem is True:
129
138
  markerline, stemlines, baseline = signal_ax.stem(x, y)
@@ -131,7 +140,10 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab
131
140
  stemlines.set_color(colors[i])
132
141
  baseline.set_color("k")
133
142
  else:
134
- signal_ax.plot(x, y, color=colors[i])
143
+ if fmt is not None:
144
+ signal_ax.plot(x, y, fmt[i], markersize=4)
145
+ else:
146
+ signal_ax.plot(x, y, color=colors[i])
135
147
 
136
148
  elif len(signal) == 2:
137
149
  y, x = signal[0], signal[1]
@@ -142,7 +154,10 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab
142
154
  stemlines.set_color(colors[i])
143
155
  baseline.set_color("k")
144
156
  else:
145
- signal_ax.plot(x, y, color=colors[i], label=legend[i])
157
+ if fmt is not None:
158
+ signal_ax.plot(x, y, fmt[i], markersize=4, label=legend[i])
159
+ else:
160
+ signal_ax.plot(x, y, color=colors[i], label=legend[i])
146
161
  else:
147
162
  if show_stem is True:
148
163
  markerline, stemlines, baseline = signal_ax.stem(x, y)
@@ -150,7 +165,11 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab
150
165
  stemlines.set_color(colors[i])
151
166
  baseline.set_color("k")
152
167
  else:
153
- signal_ax.plot(x, y, color=colors[i])
168
+ if fmt is not None:
169
+ signal_ax.plot(x, y, fmt[i], markersize=4)
170
+ else:
171
+ signal_ax.plot(x, y, color=colors[i])
172
+
154
173
 
155
174
  # Add annotations
156
175
  if ann is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: modusa
3
- Version: 0.3.4.dev1
3
+ Version: 0.3.4.dev2
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.4.dev1.dist-info/METADATA,sha256=iBr5dj4iTZe0wWwlSKVMFqM5Cx9FrUEEAdkt7_QgwTo,1373
2
- modusa-0.3.4.dev1.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
- modusa-0.3.4.dev1.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
4
- modusa-0.3.4.dev1.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
1
+ modusa-0.3.4.dev2.dist-info/METADATA,sha256=_m94ejVuu9MWxNCx_EftQuKBnLBYaQoIRU505siP2LU,1373
2
+ modusa-0.3.4.dev2.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
+ modusa-0.3.4.dev2.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
4
+ modusa-0.3.4.dev2.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=KQ94DhZj5ZJr7OhlUslRmtJ938S5ZCDsY0iXrY5QIyc,17656
50
+ modusa/tools/plotter.py,sha256=mBJTPjOkwchGlJ-9KhNDLdADNIfkdKGpIfKfjwzzDus,18298
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.4.dev1.dist-info/RECORD,,
59
+ modusa-0.3.4.dev2.dist-info/RECORD,,