iplotx 1.6.0__py3-none-any.whl → 1.7.0__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.
iplotx/plotting.py
CHANGED
|
@@ -20,6 +20,7 @@ from .network import NetworkArtist
|
|
|
20
20
|
from .network.groups import GroupingCollection
|
|
21
21
|
from .tree import TreeArtist
|
|
22
22
|
from .style import context
|
|
23
|
+
from .utils.matplotlib import _heuristic_show
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
def network(
|
|
@@ -36,6 +37,7 @@ def network(
|
|
|
36
37
|
margins: float | tuple[float, float] | tuple[float, float, float] = 0,
|
|
37
38
|
strip_axes: bool = True,
|
|
38
39
|
figsize: Optional[tuple[float, float]] = None,
|
|
40
|
+
show: Optional[bool] = None,
|
|
39
41
|
**kwargs,
|
|
40
42
|
) -> list[mpl.artist.Artist]:
|
|
41
43
|
"""Plot this network and/or vertex grouping using the specified layout.
|
|
@@ -70,6 +72,9 @@ def network(
|
|
|
70
72
|
figsize: If ax is None, a new matplotlib Figure is created. This argument specifies
|
|
71
73
|
the (width, height) dimension of the figure in inches. If ax is not None, this
|
|
72
74
|
argument is ignored. If None, the default matplotlib figure size is used.
|
|
75
|
+
show: If True, call plt.show() after plotting. If False, do not call plt.show(). If
|
|
76
|
+
None (default), try to guess based on the environment and do not show in case of
|
|
77
|
+
doubt.
|
|
73
78
|
kwargs: Additional arguments are treated as an alternate way to specify style. If
|
|
74
79
|
both "style" and additional **kwargs are provided, they are both applied in that
|
|
75
80
|
order (style, then **kwargs).
|
|
@@ -78,7 +83,12 @@ def network(
|
|
|
78
83
|
A list of mpl.artist.Artist objects, set as a direct child of the matplotlib Axes.
|
|
79
84
|
The list can have one or two elements, depending on whether you are requesting to
|
|
80
85
|
plot a network, a grouping, or both.
|
|
86
|
+
|
|
87
|
+
NOTE: If your plots are now showing to screen, try passing show=True.
|
|
81
88
|
"""
|
|
89
|
+
if show is None:
|
|
90
|
+
show = _heuristic_show()
|
|
91
|
+
|
|
82
92
|
# Equivalence of node_labels and vertex_labels
|
|
83
93
|
if node_labels is not None:
|
|
84
94
|
vertex_labels = node_labels
|
|
@@ -164,6 +174,9 @@ def network(
|
|
|
164
174
|
if (margins[0] != 0) or (margins[1] != 0) or ((len(margins) == 3) and (margins[2] != 0)):
|
|
165
175
|
ax.margins(*margins)
|
|
166
176
|
|
|
177
|
+
if show:
|
|
178
|
+
plt.show()
|
|
179
|
+
|
|
167
180
|
return artists
|
|
168
181
|
|
|
169
182
|
|
|
@@ -187,6 +200,7 @@ def tree(
|
|
|
187
200
|
margins: float | tuple[float, float] = 0,
|
|
188
201
|
strip_axes: bool = True,
|
|
189
202
|
figsize: Optional[tuple[float, float]] = None,
|
|
203
|
+
show: Optional[bool] = None,
|
|
190
204
|
**kwargs,
|
|
191
205
|
) -> TreeArtist:
|
|
192
206
|
"""Plot a tree using the specified layout.
|
|
@@ -226,13 +240,21 @@ def tree(
|
|
|
226
240
|
figsize: If ax is None, a new matplotlib Figure is created. This argument specifies
|
|
227
241
|
the (width, height) dimension of the figure in inches. If ax is not None, this
|
|
228
242
|
argument is ignored. If None, the default matplotlib figure size is used.
|
|
243
|
+
show: If True, call plt.show() after plotting. If False, do not call plt.show(). If
|
|
244
|
+
None (default), try to guess based on the environment and do not show in case of
|
|
245
|
+
doubt.
|
|
229
246
|
kwargs: Additional arguments are treated as an alternate way to specify style. If
|
|
230
247
|
both "style" and additional **kwargs are provided, they are both applied in that
|
|
231
248
|
order (style, then **kwargs).
|
|
232
249
|
|
|
233
250
|
Returns:
|
|
234
251
|
A TreeArtist object, set as a direct child of the matplotlib Axes.
|
|
252
|
+
|
|
253
|
+
NOTE: If your plots are now showing to screen, try passing show=True.
|
|
235
254
|
"""
|
|
255
|
+
if show is None:
|
|
256
|
+
show = _heuristic_show()
|
|
257
|
+
|
|
236
258
|
# Equivalence of node_labels and vertex_labels
|
|
237
259
|
if node_labels is not None:
|
|
238
260
|
vertex_labels = node_labels
|
|
@@ -270,6 +292,9 @@ def tree(
|
|
|
270
292
|
if (margins[0] != 0) or (margins[1] != 0):
|
|
271
293
|
ax.margins(*margins)
|
|
272
294
|
|
|
295
|
+
if show:
|
|
296
|
+
plt.show()
|
|
297
|
+
|
|
273
298
|
return artist
|
|
274
299
|
|
|
275
300
|
|
|
@@ -285,6 +310,7 @@ def doubletree(
|
|
|
285
310
|
margins: float | tuple[float, float] = 0,
|
|
286
311
|
strip_axes: bool = True,
|
|
287
312
|
figsize: Optional[tuple[float, float]] = None,
|
|
313
|
+
show: Optional[bool] = None,
|
|
288
314
|
) -> tuple[TreeArtist, TreeArtist]:
|
|
289
315
|
"""Visualize two trees facing each other.
|
|
290
316
|
|
|
@@ -306,9 +332,26 @@ def doubletree(
|
|
|
306
332
|
figsize: If ax is None, a new matplotlib Figure is created. This argument specifies
|
|
307
333
|
the (width, height) dimension of the figure in inches. If ax is not None, this
|
|
308
334
|
argument is ignored. If None, the default matplotlib figure size is used.
|
|
335
|
+
show: If True, call plt.show() after plotting. If False, do not call plt.show(). If
|
|
336
|
+
None (default), try to guess based on the environment and do not show in case of
|
|
337
|
+
doubt.
|
|
309
338
|
Returns:
|
|
310
339
|
A tuple with the left and right TreeArtist objects.
|
|
340
|
+
|
|
341
|
+
NOTE: If your plots are now showing to screen, try passing show=True.
|
|
311
342
|
"""
|
|
343
|
+
if show is None:
|
|
344
|
+
show = _heuristic_show()
|
|
345
|
+
|
|
346
|
+
if kwargs_left is None:
|
|
347
|
+
kwargs_left = {}
|
|
348
|
+
if "show" not in kwargs_left:
|
|
349
|
+
kwargs_left["show"] = False
|
|
350
|
+
if kwargs_right is None:
|
|
351
|
+
kwargs_right = {}
|
|
352
|
+
if "show" not in kwargs_right:
|
|
353
|
+
kwargs_right["show"] = False
|
|
354
|
+
|
|
312
355
|
artist1 = tree(
|
|
313
356
|
tree_left,
|
|
314
357
|
layout="horizontal",
|
|
@@ -316,14 +359,11 @@ def doubletree(
|
|
|
316
359
|
ax=ax,
|
|
317
360
|
strip_axes=False,
|
|
318
361
|
figsize=figsize,
|
|
319
|
-
**kwargs_left
|
|
362
|
+
**kwargs_left,
|
|
320
363
|
)
|
|
321
364
|
|
|
322
365
|
ax = artist1.axes
|
|
323
366
|
|
|
324
|
-
if kwargs_right is None:
|
|
325
|
-
kwargs_right = {}
|
|
326
|
-
|
|
327
367
|
had_layout_start = "layout_start" in kwargs_right
|
|
328
368
|
|
|
329
369
|
artist2 = tree(
|
|
@@ -348,6 +388,9 @@ def doubletree(
|
|
|
348
388
|
|
|
349
389
|
_postprocess_axes(ax, [artist1, artist2], strip=strip_axes, ignore_previous=True)
|
|
350
390
|
|
|
391
|
+
if show:
|
|
392
|
+
plt.show()
|
|
393
|
+
|
|
351
394
|
return (artist1, artist2)
|
|
352
395
|
|
|
353
396
|
|
iplotx/utils/matplotlib.py
CHANGED
|
@@ -282,3 +282,8 @@ def _get_data_scale(X, Y, Z):
|
|
|
282
282
|
ptp_y = Y.max() - Y.min()
|
|
283
283
|
ptp_z = Z.max() - Z.min()
|
|
284
284
|
return np.sqrt(ptp_x**2 + ptp_y**2 + ptp_z**2)
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def _heuristic_show():
|
|
288
|
+
"""Try guessing whether plt.show() should be called automatically."""
|
|
289
|
+
return False
|
iplotx/version.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: iplotx
|
|
3
|
-
Version: 1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 1.7.0
|
|
4
|
+
Summary: Universal network and tree visualisation library.
|
|
5
5
|
Project-URL: Homepage, https://github.com/fabilab/iplotx
|
|
6
6
|
Project-URL: Documentation, https://readthedocs.org/iplotx
|
|
7
7
|
Project-URL: Repository, https://github.com/fabilab/iplotx.git
|
|
@@ -41,7 +41,7 @@ Description-Content-Type: text/markdown
|
|
|
41
41
|
[](https://iplotx.readthedocs.io/en/latest/)
|
|
42
42
|
[](https://coveralls.io/github/fabilab/iplotx?branch=main)
|
|
43
43
|

|
|
44
|
-
[
|
|
44
|
+
[DOI](https://f1000research.com/articles/14-1377)
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
# iplotx
|
|
@@ -90,10 +90,10 @@ See [readthedocs](https://iplotx.readthedocs.io/en/latest/) for the full documen
|
|
|
90
90
|
See [gallery](https://iplotx.readthedocs.io/en/latest/gallery/index.html).
|
|
91
91
|
|
|
92
92
|
## Citation
|
|
93
|
-
If you use `iplotx` for publication figures, please cite
|
|
93
|
+
If you use `iplotx` for publication figures, please cite:
|
|
94
94
|
|
|
95
95
|
```
|
|
96
|
-
F. Zanini.
|
|
96
|
+
F. Zanini. A universal tool for visualisation of networks and trees in Python. F1000Research 2025, 14:1377. https://doi.org/10.12688/f1000research.173131.1
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
## Features
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
iplotx/__init__.py,sha256=RKlRSSEAv2qECd6rCiovdLDu-4k1eXMGCOCPt0xwpFA,523
|
|
2
2
|
iplotx/artists.py,sha256=2dBDT240zGwKb6tIc_y9pXeyU3LuYeF9wjj2tvi4KJo,730
|
|
3
3
|
iplotx/label.py,sha256=7eS8ByadrhdIFOZz19U4VrS-oXY_ndFYNB-D4RZbFqI,9573
|
|
4
|
-
iplotx/plotting.py,sha256=
|
|
4
|
+
iplotx/plotting.py,sha256=QlXCh3t1J9YmzkqrS6ozwSilFxZ1hwBHHWW-kpd-7zM,17679
|
|
5
5
|
iplotx/typing.py,sha256=QLdzV358IiD1CFe88MVp0D77FSx5sSAVUmM_2WPPE8I,1463
|
|
6
|
-
iplotx/version.py,sha256=
|
|
6
|
+
iplotx/version.py,sha256=7dTkHVHx2G_FnFiWdcEX1gkeNeCO9nu53SE10IwwwKM,66
|
|
7
7
|
iplotx/vertex.py,sha256=Ta48M_6ZT8xKQWdI5XHiRxTt2LlJ9vshiDk34OzKYlY,16585
|
|
8
8
|
iplotx/art3d/vertex.py,sha256=Xf8Um30X2doCd8KdNN7332F6BxC4k72Mb_GeRAuzQfQ,2545
|
|
9
9
|
iplotx/art3d/edge/__init__.py,sha256=uw1U_mMXqcZAvea-7JbU1PUKULQD1CMMrbwY02tiWRQ,8529
|
|
@@ -41,8 +41,8 @@ iplotx/tree/cascades.py,sha256=Wwqhy46QGeb4LNGUuz_-bgNWUMz6PFzs_dIxIb1dtqc,8394
|
|
|
41
41
|
iplotx/tree/scalebar.py,sha256=Yxt_kF8JdTwKGa8Jzqt3qVePPK5ZBG8P0EiONrsh3E8,11863
|
|
42
42
|
iplotx/utils/geometry.py,sha256=6RrC6qaB0-1vIk1LhGA4CfsiMd-9JNniSPyL_l9mshE,9245
|
|
43
43
|
iplotx/utils/internal.py,sha256=WWfcZDGK8Ut1y_tOHRGg9wSqY1bwSeLQO7dHM_8Tvwo,107
|
|
44
|
-
iplotx/utils/matplotlib.py,sha256=
|
|
44
|
+
iplotx/utils/matplotlib.py,sha256=T-jiqy8KxF1Q4BofT1rZbbdtmSC-j_kjNRcOg_IZpYM,8720
|
|
45
45
|
iplotx/utils/style.py,sha256=vyNP80nDYVinqm6_9ltCJCtjK35ZcGlHvOskNv3eQBc,4225
|
|
46
|
-
iplotx-1.
|
|
47
|
-
iplotx-1.
|
|
48
|
-
iplotx-1.
|
|
46
|
+
iplotx-1.7.0.dist-info/METADATA,sha256=gItmBkiLmtBY73aY3IIycXX61yghAdv0wBmMXsDBpSw,5333
|
|
47
|
+
iplotx-1.7.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
48
|
+
iplotx-1.7.0.dist-info/RECORD,,
|