modusa 0.3.48__py3-none-any.whl → 0.3.51__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 +56 -12
- {modusa-0.3.48.dist-info → modusa-0.3.51.dist-info}/METADATA +1 -1
- {modusa-0.3.48.dist-info → modusa-0.3.51.dist-info}/RECORD +6 -6
- {modusa-0.3.48.dist-info → modusa-0.3.51.dist-info}/WHEEL +0 -0
- {modusa-0.3.48.dist-info → modusa-0.3.51.dist-info}/entry_points.txt +0 -0
- {modusa-0.3.48.dist-info → modusa-0.3.51.dist-info}/licenses/LICENSE.md +0 -0
    
        modusa/tools/plotter.py
    CHANGED
    
    | @@ -915,14 +915,14 @@ class Fig: | |
| 915 915 |  | 
| 916 916 | 
             
            	"""
         | 
| 917 917 |  | 
| 918 | 
            -
            	def __init__(self, arrangement="asm",  | 
| 918 | 
            +
            	def __init__(self, arrangement="asm", xlim=None):
         | 
| 919 919 |  | 
| 920 920 | 
             
            		self._xlim = xlim
         | 
| 921 921 | 
             
            		self._curr_row_idx = 1 # Starting from 1 because row 0 is reserved for reference subplot
         | 
| 922 922 | 
             
            		self._curr_color_idx = 0 # So that we have different color across all the subplots to avoid legend confusion
         | 
| 923 923 |  | 
| 924 924 | 
             
            		# Subplot setup
         | 
| 925 | 
            -
            		self._fig, self._axs = self._generate_subplots(arrangement | 
| 925 | 
            +
            		self._fig, self._axs = self._generate_subplots(arrangement) # This will fill in the all the above variables
         | 
| 926 926 |  | 
| 927 927 |  | 
| 928 928 | 
             
            	def _get_curr_row(self):
         | 
| @@ -958,7 +958,7 @@ class Fig: | |
| 958 958 | 
             
            		return [x[0] - dx / 2, x[-1] + dx / 2, y[0] - dy / 2, y[-1] + dy / 2]
         | 
| 959 959 |  | 
| 960 960 |  | 
| 961 | 
            -
            	def _generate_subplots(self, arrangement | 
| 961 | 
            +
            	def _generate_subplots(self, arrangement):
         | 
| 962 962 | 
             
            		"""
         | 
| 963 963 | 
             
            		Generate subplots based on the configuration.
         | 
| 964 964 | 
             
            		"""
         | 
| @@ -1013,12 +1013,6 @@ class Fig: | |
| 1013 1013 | 
             
            		# xlim should be applied on reference subplot, rest all subplots will automatically adjust
         | 
| 1014 1014 | 
             
            		if xlim is not None:
         | 
| 1015 1015 | 
             
            			axs[0, 0].set_xlim(xlim)
         | 
| 1016 | 
            -
            			
         | 
| 1017 | 
            -
            		# Set title and label
         | 
| 1018 | 
            -
            		if title is not None:
         | 
| 1019 | 
            -
            			axs[0, 0].set_title(title)
         | 
| 1020 | 
            -
            		if xlabel is not None:
         | 
| 1021 | 
            -
            			axs[-1, 0].set_xlabel(xlabel)
         | 
| 1022 1016 |  | 
| 1023 1017 | 
             
            		fig.subplots_adjust(hspace=0.2, wspace=0.05)
         | 
| 1024 1018 |  | 
| @@ -1103,7 +1097,7 @@ class Fig: | |
| 1103 1097 | 
             
            		label: str
         | 
| 1104 1098 | 
             
            			- Label for the plot.
         | 
| 1105 1099 | 
             
            			- Legend will use this.
         | 
| 1106 | 
            -
            			- Default:  | 
| 1100 | 
            +
            			- Default: None
         | 
| 1107 1101 | 
             
            		ylabel: str
         | 
| 1108 1102 | 
             
            			- y-label for the plot.
         | 
| 1109 1103 | 
             
            			- Default: None
         | 
| @@ -1159,7 +1153,7 @@ class Fig: | |
| 1159 1153 | 
             
            		label: str
         | 
| 1160 1154 | 
             
            			- Label for the event type.
         | 
| 1161 1155 | 
             
            			- This will appear in the legend.
         | 
| 1162 | 
            -
            			- Default:  | 
| 1156 | 
            +
            			- Default: None
         | 
| 1163 1157 | 
             
            		ax: int
         | 
| 1164 1158 | 
             
            			- Which specific axis to plot (1, 2, 3, ...)
         | 
| 1165 1159 | 
             
            			- None
         | 
| @@ -1188,7 +1182,7 @@ class Fig: | |
| 1188 1182 | 
             
            				else:
         | 
| 1189 1183 | 
             
            					curr_row[0].axvline(x=event, color=c, linestyle=ls, linewidth=lw)
         | 
| 1190 1184 |  | 
| 1191 | 
            -
            	def add_annotation(self, ann, ax=None):
         | 
| 1185 | 
            +
            	def add_annotation(self, ann, label=None, ax=None):
         | 
| 1192 1186 | 
             
            		"""
         | 
| 1193 1187 | 
             
            		Add annotation to the figure.
         | 
| 1194 1188 |  | 
| @@ -1197,6 +1191,10 @@ class Fig: | |
| 1197 1191 | 
             
            		ann : list[tuple[Number, Number, str]] | None
         | 
| 1198 1192 | 
             
            			- A list of annotation spans. Each tuple should be (start, end, label).
         | 
| 1199 1193 | 
             
            			- Default: None (no annotations).
         | 
| 1194 | 
            +
            		label: str
         | 
| 1195 | 
            +
            			- Label for the annotation type.
         | 
| 1196 | 
            +
            			- This will appear to the right of the aux plot.
         | 
| 1197 | 
            +
            			- Default: None
         | 
| 1200 1198 | 
             
            		ax: int
         | 
| 1201 1199 | 
             
            			- Which specific axis to plot (1, 2, 3, ...)
         | 
| 1202 1200 | 
             
            			- None
         | 
| @@ -1248,6 +1246,11 @@ class Fig: | |
| 1248 1246 |  | 
| 1249 1247 | 
             
            				text_obj.set_clip_path(rect)
         | 
| 1250 1248 |  | 
| 1249 | 
            +
            		if label is not None:
         | 
| 1250 | 
            +
            			curr_row[0].set_ylabel(label, rotation=0, ha="center", va="center")
         | 
| 1251 | 
            +
            			curr_row[0].yaxis.set_label_position("right")
         | 
| 1252 | 
            +
            			curr_row[0].yaxis.set_label_coords(1.05, 0.75)
         | 
| 1253 | 
            +
            				
         | 
| 1251 1254 | 
             
            	def add_legend(self, ypos=1.0):
         | 
| 1252 1255 | 
             
            		"""
         | 
| 1253 1256 | 
             
            		Add legend to the figure.
         | 
| @@ -1276,6 +1279,47 @@ class Fig: | |
| 1276 1279 | 
             
            		# remove duplicates if needed
         | 
| 1277 1280 | 
             
            		fig.legend(all_handles, all_labels, loc='upper right', bbox_to_anchor=(0.95, ypos), ncol=2, frameon=True, bbox_transform=fig.transFigure)
         | 
| 1278 1281 |  | 
| 1282 | 
            +
            	def add_title(self, title=None, s=13):
         | 
| 1283 | 
            +
            		"""
         | 
| 1284 | 
            +
            		Add title to the figure.
         | 
| 1285 | 
            +
             | 
| 1286 | 
            +
            		Parameters
         | 
| 1287 | 
            +
            		----------
         | 
| 1288 | 
            +
            		title: str | None
         | 
| 1289 | 
            +
            			- Title of the figure.
         | 
| 1290 | 
            +
            			- Default: None
         | 
| 1291 | 
            +
            		s: Number
         | 
| 1292 | 
            +
            			- Font size.
         | 
| 1293 | 
            +
            			- Default: None
         | 
| 1294 | 
            +
            		"""
         | 
| 1295 | 
            +
            		axs = self._axs
         | 
| 1296 | 
            +
            		ref_ax = axs[0, 0] # Title is added to the top subplot (ref subplot)
         | 
| 1297 | 
            +
            		
         | 
| 1298 | 
            +
            		if title is not None:
         | 
| 1299 | 
            +
            			ref_ax.set_title(title, pad=10, size=s)
         | 
| 1300 | 
            +
            	
         | 
| 1301 | 
            +
            		
         | 
| 1302 | 
            +
            	def add_xlabel(self, xlabel=None, s=None):
         | 
| 1303 | 
            +
            		"""
         | 
| 1304 | 
            +
            		Add shared x-label to the figure.
         | 
| 1305 | 
            +
             | 
| 1306 | 
            +
            		Parameters
         | 
| 1307 | 
            +
            		----------
         | 
| 1308 | 
            +
            		xlabel: str | None
         | 
| 1309 | 
            +
            			- xlabel for the figure.
         | 
| 1310 | 
            +
            			- Default: None
         | 
| 1311 | 
            +
            		s: Number
         | 
| 1312 | 
            +
            			- Font size.
         | 
| 1313 | 
            +
            			- Default: None
         | 
| 1314 | 
            +
            		"""
         | 
| 1315 | 
            +
            		axs = self._axs
         | 
| 1316 | 
            +
            		ref_ax = axs[-1, 0] # X-label is added to the last subplot
         | 
| 1317 | 
            +
            		if xlabel is not None:
         | 
| 1318 | 
            +
            			ref_ax.set_xlabel(xlabel, size=s)
         | 
| 1319 | 
            +
            	
         | 
| 1320 | 
            +
            	def add_xticks():
         | 
| 1321 | 
            +
            		raise NotImplementedError("Please raise a github issue `https://github.com/meluron-toolbox/modusa/issues`")
         | 
| 1322 | 
            +
            		
         | 
| 1279 1323 | 
             
            	def save(self, path="./figure.png"):
         | 
| 1280 1324 | 
             
            		"""
         | 
| 1281 1325 | 
             
            		Save the figure.
         | 
| @@ -1,7 +1,7 @@ | |
| 1 | 
            -
            modusa-0.3. | 
| 2 | 
            -
            modusa-0.3. | 
| 3 | 
            -
            modusa-0.3. | 
| 4 | 
            -
            modusa-0.3. | 
| 1 | 
            +
            modusa-0.3.51.dist-info/METADATA,sha256=Z_j4qx-H1R16_hDhBJDu-fv8WBFcHfUsQGzN9zOanC4,1436
         | 
| 2 | 
            +
            modusa-0.3.51.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
         | 
| 3 | 
            +
            modusa-0.3.51.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
         | 
| 4 | 
            +
            modusa-0.3.51.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=_Fk3GxsI0GT-uhsZaHgs6p5YcIkqPGb3s78_dzFy1lE,291
         | 
| 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=KD15NHcOU-vA-12VTk5qYYXuiSdhCpwd2QFjkx76I4E,35040
         | 
| 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.51.dist-info/RECORD,,
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         |