modusa 0.3.29__py3-none-any.whl → 0.3.30__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 +55 -33
- {modusa-0.3.29.dist-info → modusa-0.3.30.dist-info}/METADATA +1 -1
- {modusa-0.3.29.dist-info → modusa-0.3.30.dist-info}/RECORD +6 -6
- {modusa-0.3.29.dist-info → modusa-0.3.30.dist-info}/WHEEL +0 -0
- {modusa-0.3.29.dist-info → modusa-0.3.30.dist-info}/entry_points.txt +0 -0
- {modusa-0.3.29.dist-info → modusa-0.3.30.dist-info}/licenses/LICENSE.md +0 -0
    
        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,34 @@ 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 | 
            -
            					 | 
| 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 | 
            -
            					 | 
| 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 | 
            -
            					 | 
| 139 | 
            +
            					if show_stem is True:
         | 
| 140 | 
            +
            						signal_ax.stem(x, y, linefmt=f"{colors[i]}-", markerfmt=f"{colors[i]}o", basefmt="k-", label=legend[i])
         | 
| 141 | 
            +
            					else:
         | 
| 142 | 
            +
            						signal_ax.plot(x, y, color=colors[i], label=legend[i])
         | 
| 124 143 | 
             
            				else:
         | 
| 125 | 
            -
            					 | 
| 144 | 
            +
            					if show_stem is True:
         | 
| 145 | 
            +
            						signal_ax.stem(x, y, linefmt=f"{colors[i]}-", markerfmt=f"{colors[i]}o", basefmt="k-")
         | 
| 146 | 
            +
            					else:
         | 
| 147 | 
            +
            						signal_ax.plot(x, y, color=colors[i])
         | 
| 126 148 |  | 
| 127 149 | 
             
            		# Add annotations
         | 
| 128 150 | 
             
            		if ann is not None:
         | 
| @@ -166,7 +188,7 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab | |
| 166 188 | 
             
            		# Add legend
         | 
| 167 189 | 
             
            		if legend is not None:
         | 
| 168 190 | 
             
            			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= | 
| 191 | 
            +
            			fig.legend(handles, labels, loc='upper right', bbox_to_anchor=(0.9, 1.2), ncol=len(legend), frameon=True)
         | 
| 170 192 |  | 
| 171 193 | 
             
            		# Set title, labels
         | 
| 172 194 | 
             
            		if title is not None:
         | 
| @@ -463,11 +485,11 @@ def plot_dist(*args, ann=None, xlim=None, ylim=None, ylabel=None, xlabel=None, t | |
| 463 485 | 
             
            		from scipy.stats import gaussian_kde
         | 
| 464 486 |  | 
| 465 487 | 
             
            		if isinstance(legend, str):
         | 
| 466 | 
            -
             | 
| 488 | 
            +
            			legend = (legend, )
         | 
| 467 489 |  | 
| 468 490 | 
             
            		if legend is not None:
         | 
| 469 | 
            -
             | 
| 470 | 
            -
             | 
| 491 | 
            +
            			if len(legend) < len(args):
         | 
| 492 | 
            +
            				raise ValueError(f"Legend should be provided for each signal.")
         | 
| 471 493 |  | 
| 472 494 | 
             
            		# Create figure
         | 
| 473 495 | 
             
            		fig = plt.figure(figsize=(16, 4))
         | 
| @@ -480,28 +502,28 @@ def plot_dist(*args, ann=None, xlim=None, ylim=None, ylabel=None, xlabel=None, t | |
| 480 502 |  | 
| 481 503 | 
             
            		# Set limits
         | 
| 482 504 | 
             
            		if xlim is not None:
         | 
| 483 | 
            -
             | 
| 505 | 
            +
            			dist_ax.set_xlim(xlim)
         | 
| 484 506 |  | 
| 485 507 | 
             
            		if ylim is not None:
         | 
| 486 | 
            -
             | 
| 508 | 
            +
            			dist_ax.set_ylim(ylim)
         | 
| 487 509 |  | 
| 488 510 | 
             
            		# Add plot
         | 
| 489 511 | 
             
            		for i, data in enumerate(args):
         | 
| 490 | 
            -
             | 
| 491 | 
            -
             | 
| 492 | 
            -
             | 
| 493 | 
            -
             | 
| 494 | 
            -
             | 
| 495 | 
            -
             | 
| 496 | 
            -
             | 
| 497 | 
            -
             | 
| 498 | 
            -
             | 
| 499 | 
            -
             | 
| 500 | 
            -
             | 
| 501 | 
            -
             | 
| 502 | 
            -
             | 
| 503 | 
            -
             | 
| 504 | 
            -
             | 
| 512 | 
            +
            			# Fit gaussian to the data
         | 
| 513 | 
            +
            			kde = gaussian_kde(data)
         | 
| 514 | 
            +
            		
         | 
| 515 | 
            +
            			# Create points to evaluate KDE
         | 
| 516 | 
            +
            			x = np.linspace(np.min(data), np.max(data), npoints)
         | 
| 517 | 
            +
            			y = kde(x)
         | 
| 518 | 
            +
            		
         | 
| 519 | 
            +
            			if legend is not None:
         | 
| 520 | 
            +
            				dist_ax.plot(x, y, color=colors[i], label=legend[i])
         | 
| 521 | 
            +
            				if show_hist is True:
         | 
| 522 | 
            +
            					dist_ax.hist(data, bins=bins, density=True, alpha=0.3, facecolor=colors[i], edgecolor='black', label=legend[i])
         | 
| 523 | 
            +
            			else:
         | 
| 524 | 
            +
            				dist_ax.plot(x, y, color=colors[i])
         | 
| 525 | 
            +
            				if show_hist is True:
         | 
| 526 | 
            +
            					dist_ax.hist(data, bins=bins, density=True, alpha=0.3, facecolor=colors[i], edgecolor='black')
         | 
| 505 527 |  | 
| 506 528 | 
             
            		# Add annotations
         | 
| 507 529 | 
             
            		if ann is not None:
         | 
| @@ -528,22 +550,22 @@ def plot_dist(*args, ann=None, xlim=None, ylim=None, ylabel=None, xlabel=None, t | |
| 528 550 |  | 
| 529 551 | 
             
            		# Add legend
         | 
| 530 552 | 
             
            		if legend is not None:
         | 
| 531 | 
            -
             | 
| 532 | 
            -
             | 
| 553 | 
            +
            			handles, labels = dist_ax.get_legend_handles_labels()
         | 
| 554 | 
            +
            			fig.legend(handles, labels, loc='upper right', bbox_to_anchor=(0.9, 1.1), ncol=len(legend), frameon=True)
         | 
| 533 555 |  | 
| 534 556 | 
             
            		# Set title, labels
         | 
| 535 557 | 
             
            		if title is not None:
         | 
| 536 | 
            -
             | 
| 558 | 
            +
            			annotation_ax.set_title(title, pad=10, size=11)
         | 
| 537 559 | 
             
            		if xlabel is not None:
         | 
| 538 | 
            -
             | 
| 560 | 
            +
            			dist_ax.set_xlabel(xlabel)
         | 
| 539 561 | 
             
            		if ylabel is not None:
         | 
| 540 | 
            -
             | 
| 562 | 
            +
            			dist_ax.set_ylabel(ylabel)
         | 
| 541 563 |  | 
| 542 564 | 
             
            		# Remove the boundaries and ticks from annotation axis
         | 
| 543 565 | 
             
            		if ann is not None:
         | 
| 544 | 
            -
             | 
| 566 | 
            +
            			annotation_ax.tick_params(left=False, bottom=False, labelleft=False, labelbottom=False)
         | 
| 545 567 | 
             
            		else:
         | 
| 546 | 
            -
             | 
| 568 | 
            +
            			annotation_ax.axis("off")
         | 
| 547 569 |  | 
| 548 570 | 
             
            		fig.subplots_adjust(hspace=0.01, wspace=0.05)
         | 
| 549 571 | 
             
            		plt.close()
         | 
| @@ -1,7 +1,7 @@ | |
| 1 | 
            -
            modusa-0.3. | 
| 2 | 
            -
            modusa-0.3. | 
| 3 | 
            -
            modusa-0.3. | 
| 4 | 
            -
            modusa-0.3. | 
| 1 | 
            +
            modusa-0.3.30.dist-info/METADATA,sha256=ue8QCA3HR90-JBEZkGmfM-up5D6tFqn88u2QqGrdHd8,1369
         | 
| 2 | 
            +
            modusa-0.3.30.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
         | 
| 3 | 
            +
            modusa-0.3.30.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
         | 
| 4 | 
            +
            modusa-0.3.30.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= | 
| 50 | 
            +
            modusa/tools/plotter.py,sha256=rIv5TmKtr9uliRcLNRjmejwvIixZqpUf4_dtqSlx2Hg,17510
         | 
| 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. | 
| 59 | 
            +
            modusa-0.3.30.dist-info/RECORD,,
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         |