iplotx 0.2.1__tar.gz → 0.3.1__tar.gz

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.
Files changed (156) hide show
  1. {iplotx-0.2.1 → iplotx-0.3.1}/.github/workflows/publish.yml +22 -7
  2. {iplotx-0.2.1 → iplotx-0.3.1}/PKG-INFO +2 -1
  3. {iplotx-0.2.1 → iplotx-0.3.1}/README.md +1 -0
  4. {iplotx-0.2.1 → iplotx-0.3.1}/docs/source/index.md +3 -1
  5. {iplotx-0.2.1 → iplotx-0.3.1}/docs/source/sg_execution_times.rst +17 -5
  6. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_biopython_tree.py +1 -0
  7. iplotx-0.3.1/gallery/plot_company_structure.py +72 -0
  8. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_edit_artists.py +1 -0
  9. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_ete4.py +15 -2
  10. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_loops.py +4 -4
  11. iplotx-0.3.1/gallery/plot_mouse_hover.py +67 -0
  12. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_simple_path.py +2 -2
  13. iplotx-0.3.1/gallery/plot_tree_node_background.py +55 -0
  14. iplotx-0.3.1/gallery/plot_trees_of_trees.py +83 -0
  15. iplotx-0.3.1/iplotx/cascades.py +223 -0
  16. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/edge/__init__.py +20 -1
  17. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/edge/geometry.py +72 -16
  18. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/ingest/__init__.py +12 -4
  19. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/ingest/heuristics.py +1 -3
  20. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/ingest/providers/network/igraph.py +4 -2
  21. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/ingest/providers/network/networkx.py +4 -2
  22. iplotx-0.3.1/iplotx/ingest/providers/tree/biopython.py +47 -0
  23. iplotx-0.3.1/iplotx/ingest/providers/tree/cogent3.py +41 -0
  24. iplotx-0.3.1/iplotx/ingest/providers/tree/ete4.py +44 -0
  25. iplotx-0.3.1/iplotx/ingest/providers/tree/skbio.py +41 -0
  26. iplotx-0.3.1/iplotx/ingest/typing.py +303 -0
  27. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/label.py +55 -8
  28. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/layout.py +56 -35
  29. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/plotting.py +6 -3
  30. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/style.py +19 -5
  31. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/tree.py +189 -8
  32. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/version.py +1 -1
  33. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/vertex.py +39 -7
  34. iplotx-0.3.1/scripts/copy_github_release_into_version.sh +16 -0
  35. iplotx-0.3.1/tests/baseline_images/test_biopython/leaf_labels.png +0 -0
  36. iplotx-0.3.1/tests/baseline_images/test_biopython/leaf_labels_hmargin.png +0 -0
  37. iplotx-0.3.1/tests/baseline_images/test_biopython/tree_radial.png +0 -0
  38. iplotx-0.3.1/tests/baseline_images/test_cogent3/leaf_labels.png +0 -0
  39. iplotx-0.3.1/tests/baseline_images/test_cogent3/leaf_labels_hmargin.png +0 -0
  40. iplotx-0.3.1/tests/baseline_images/test_cogent3/tree_radial.png +0 -0
  41. iplotx-0.3.1/tests/baseline_images/test_ete4/leaf_labels.png +0 -0
  42. iplotx-0.3.1/tests/baseline_images/test_ete4/leaf_labels_hmargin.png +0 -0
  43. iplotx-0.3.1/tests/baseline_images/test_ete4/tree_radial.png +0 -0
  44. iplotx-0.3.1/tests/baseline_images/test_networkx/simple_graph.png +0 -0
  45. iplotx-0.3.1/tests/baseline_images/test_skbio/leaf_labels.png +0 -0
  46. iplotx-0.3.1/tests/baseline_images/test_skbio/leaf_labels_hmargin.png +0 -0
  47. iplotx-0.3.1/tests/baseline_images/test_skbio/tree_radial.png +0 -0
  48. {iplotx-0.2.1 → iplotx-0.3.1}/tests/test_biopython.py +1 -1
  49. {iplotx-0.2.1 → iplotx-0.3.1}/tests/test_cogent3.py +1 -1
  50. {iplotx-0.2.1 → iplotx-0.3.1}/tests/test_ete4.py +1 -1
  51. {iplotx-0.2.1 → iplotx-0.3.1}/tests/test_igraph.py +2 -2
  52. {iplotx-0.2.1 → iplotx-0.3.1}/tests/test_networkx.py +1 -1
  53. {iplotx-0.2.1 → iplotx-0.3.1}/tests/test_skbio.py +1 -1
  54. iplotx-0.2.1/iplotx/ingest/providers/tree/biopython.py +0 -105
  55. iplotx-0.2.1/iplotx/ingest/providers/tree/cogent3.py +0 -112
  56. iplotx-0.2.1/iplotx/ingest/providers/tree/ete4.py +0 -112
  57. iplotx-0.2.1/iplotx/ingest/providers/tree/skbio.py +0 -112
  58. iplotx-0.2.1/iplotx/ingest/typing.py +0 -100
  59. iplotx-0.2.1/tests/baseline_images/test_biopython/leaf_labels.png +0 -0
  60. iplotx-0.2.1/tests/baseline_images/test_biopython/leaf_labels_hmargin.png +0 -0
  61. iplotx-0.2.1/tests/baseline_images/test_biopython/tree_radial.png +0 -0
  62. iplotx-0.2.1/tests/baseline_images/test_cogent3/leaf_labels.png +0 -0
  63. iplotx-0.2.1/tests/baseline_images/test_cogent3/leaf_labels_hmargin.png +0 -0
  64. iplotx-0.2.1/tests/baseline_images/test_cogent3/tree_radial.png +0 -0
  65. iplotx-0.2.1/tests/baseline_images/test_ete4/leaf_labels.png +0 -0
  66. iplotx-0.2.1/tests/baseline_images/test_ete4/leaf_labels_hmargin.png +0 -0
  67. iplotx-0.2.1/tests/baseline_images/test_ete4/tree_radial.png +0 -0
  68. iplotx-0.2.1/tests/baseline_images/test_networkx/simple_graph.png +0 -0
  69. iplotx-0.2.1/tests/baseline_images/test_skbio/leaf_labels.png +0 -0
  70. iplotx-0.2.1/tests/baseline_images/test_skbio/leaf_labels_hmargin.png +0 -0
  71. iplotx-0.2.1/tests/baseline_images/test_skbio/tree_radial.png +0 -0
  72. {iplotx-0.2.1 → iplotx-0.3.1}/.github/workflows/test.yml +0 -0
  73. {iplotx-0.2.1 → iplotx-0.3.1}/.gitignore +0 -0
  74. {iplotx-0.2.1 → iplotx-0.3.1}/.readthedocs.yaml +0 -0
  75. {iplotx-0.2.1 → iplotx-0.3.1}/LICENSE +0 -0
  76. {iplotx-0.2.1 → iplotx-0.3.1}/MANIFEST.in +0 -0
  77. {iplotx-0.2.1 → iplotx-0.3.1}/assets/pylint.svg +0 -0
  78. {iplotx-0.2.1 → iplotx-0.3.1}/docs/Makefile +0 -0
  79. {iplotx-0.2.1 → iplotx-0.3.1}/docs/make.bat +0 -0
  80. {iplotx-0.2.1 → iplotx-0.3.1}/docs/source/_static/graph_basic.png +0 -0
  81. {iplotx-0.2.1 → iplotx-0.3.1}/docs/source/_templates/layout.html +0 -0
  82. {iplotx-0.2.1 → iplotx-0.3.1}/docs/source/api.md +0 -0
  83. {iplotx-0.2.1 → iplotx-0.3.1}/docs/source/conf.py +0 -0
  84. {iplotx-0.2.1 → iplotx-0.3.1}/docs/source/images/sphx_glr_plot_basic_001.png +0 -0
  85. {iplotx-0.2.1 → iplotx-0.3.1}/docs/source/images/thumb/sphx_glr_plot_basic_thumb.png +0 -0
  86. {iplotx-0.2.1 → iplotx-0.3.1}/docs/source/style.md +0 -0
  87. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/GALLERY_HEADER.rst +0 -0
  88. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/chess_masters_WCC.pgn.bz2 +0 -0
  89. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/knuth_miles.txt.gz +0 -0
  90. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_animation.py +0 -0
  91. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_basic.py +0 -0
  92. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_big_curves.py +0 -0
  93. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_chess_masters.py +0 -0
  94. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_cliques.py +0 -0
  95. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_cluster_layout.py +0 -0
  96. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_cogent3_tree.py +0 -0
  97. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_complex.py +0 -0
  98. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_dag.py +0 -0
  99. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_directed.py +0 -0
  100. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_four_grids.py +0 -0
  101. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_grouping.py +0 -0
  102. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_house.py +0 -0
  103. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_knuth_miles.py +0 -0
  104. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_labels_and_colors.py +0 -0
  105. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_max_bipartite_matching.py +0 -0
  106. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_minimum_spanning_trees.py +0 -0
  107. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_multipartite_layout.py +0 -0
  108. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_parallel_igraph_networkx.py +0 -0
  109. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_ports.py +0 -0
  110. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_shortest_path.py +0 -0
  111. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_simple_networkx.py +0 -0
  112. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_skbio_tree.py +0 -0
  113. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_style.py +0 -0
  114. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_traveling_salesman.py +0 -0
  115. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_voronoi.py +0 -0
  116. {iplotx-0.2.1 → iplotx-0.3.1}/gallery/plot_with_colorbar.py +0 -0
  117. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/__init__.py +0 -0
  118. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/edge/arrow.py +0 -0
  119. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/edge/ports.py +0 -0
  120. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/groups.py +0 -0
  121. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/network.py +0 -0
  122. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/typing.py +0 -0
  123. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/utils/geometry.py +0 -0
  124. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/utils/internal.py +0 -0
  125. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/utils/matplotlib.py +0 -0
  126. {iplotx-0.2.1 → iplotx-0.3.1}/iplotx/utils/style.py +0 -0
  127. {iplotx-0.2.1 → iplotx-0.3.1}/pyproject.toml +0 -0
  128. {iplotx-0.2.1 → iplotx-0.3.1}/scripts/update_pylint_badge.sh +0 -0
  129. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_biopython/tree_basic.png +0 -0
  130. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_cogent3/tree_basic.png +0 -0
  131. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_ete4/tree_basic.png +0 -0
  132. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/clustering_directed.png +0 -0
  133. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/clustering_directed_large.png +0 -0
  134. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/graph_basic.png +0 -0
  135. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/graph_directed.png +0 -0
  136. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/graph_directed_curved_loops.png +0 -0
  137. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/graph_edit_children.png +0 -0
  138. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/graph_labels.png +0 -0
  139. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/graph_layout_attribute.png +0 -0
  140. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/graph_null.png +0 -0
  141. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/graph_squares_directed.png +0 -0
  142. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/igraph_layout_object.png +0 -0
  143. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_igraph/multigraph_with_curved_edges_undirected.png +0 -0
  144. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_networkx/cluster-layout.png +0 -0
  145. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_networkx/complex.png +0 -0
  146. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_networkx/directed_graph.png +0 -0
  147. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_networkx/directed_graph_with_colorbar.png +0 -0
  148. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_networkx/empty_graph.png +0 -0
  149. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_networkx/flat_style.png +0 -0
  150. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_networkx/house_with_colors.png +0 -0
  151. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_networkx/labels_and_colors.png +0 -0
  152. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_networkx/shortest_path.png +0 -0
  153. {iplotx-0.2.1 → iplotx-0.3.1}/tests/baseline_images/test_skbio/tree_basic.png +0 -0
  154. {iplotx-0.2.1 → iplotx-0.3.1}/tests/test_style.py +0 -0
  155. {iplotx-0.2.1 → iplotx-0.3.1}/tests/utils.py +0 -0
  156. {iplotx-0.2.1 → iplotx-0.3.1}/uv.lock +0 -0
@@ -19,18 +19,33 @@ jobs:
19
19
  release-build:
20
20
  runs-on: ubuntu-latest
21
21
 
22
+ strategy:
23
+ matrix:
24
+ python-version: ["3.11"]
25
+
22
26
  steps:
23
27
  - uses: actions/checkout@v4
24
28
 
25
- - uses: actions/setup-python@v5
29
+ - name: Install uv
30
+ uses: astral-sh/setup-uv@v5
31
+ with:
32
+ python-version: ${{ matrix.python-version }}
33
+
34
+ - name: Set up Python ${{ matrix.python-version }}
35
+ uses: actions/setup-python@v5
26
36
  with:
27
- python-version: "3.x"
37
+ python-version: ${{ matrix.python-version }}
28
38
 
29
- - name: Build release distributions
39
+ - name: Install the project
30
40
  run: |
31
- # NOTE: put your own distribution build steps here.
32
- python -m pip install build
33
- python -m build
41
+ # Copy the release name into version.py (e.g. v0.3.0 -> 0.3.0)
42
+ ./scripts/copy_github_release_into_version.sh ${{ github.event.release.name }}
43
+ # Make sure you are in the right environment
44
+ uv sync
45
+ # Clean dist/
46
+ rm -f dist/*
47
+ # Build into dist/
48
+ uv build
34
49
 
35
50
  - name: Upload distributions
36
51
  uses: actions/upload-artifact@v4
@@ -51,7 +66,7 @@ jobs:
51
66
  environment:
52
67
  name: pypi
53
68
  # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
54
- # url: https://pypi.org/p/YOURPROJECT
69
+ url: https://pypi.org/p/iplotx
55
70
  #
56
71
  # ALTERNATIVE: if your GitHub Release name is the PyPI project version string
57
72
  # ALTERNATIVE: exactly, uncomment the following line instead:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iplotx
3
- Version: 0.2.1
3
+ Version: 0.3.1
4
4
  Summary: Plot networkx from igraph and networkx.
5
5
  Project-URL: Homepage, https://github.com/fabilab/iplotx
6
6
  Project-URL: Documentation, https://readthedocs.org/iplotx
@@ -79,6 +79,7 @@ See [gallery](https://iplotx.readthedocs.io/en/latest/gallery/index.html).
79
79
  - Efficient plotting of large graphs using matplotlib's collection functionality. ✅
80
80
  - Support editing plotting elements after the plot is created, e.g. changing node colors, labels, etc. ✅
81
81
  - Support animations, e.g. showing the evolution of a network over time. ✅
82
+ - Support mouse interaction, e.g. hovering over or clicking on nodes and edges to get information about them. ✅
82
83
  - Support trees from special libraries such as ete3, biopython, etc. This will need a dedicated function and layouting. ✅
83
84
  - Support uni- and bi-directional communication between graph object and plot object.🏗️
84
85
 
@@ -41,6 +41,7 @@ See [gallery](https://iplotx.readthedocs.io/en/latest/gallery/index.html).
41
41
  - Efficient plotting of large graphs using matplotlib's collection functionality. ✅
42
42
  - Support editing plotting elements after the plot is created, e.g. changing node colors, labels, etc. ✅
43
43
  - Support animations, e.g. showing the evolution of a network over time. ✅
44
+ - Support mouse interaction, e.g. hovering over or clicking on nodes and edges to get information about them. ✅
44
45
  - Support trees from special libraries such as ete3, biopython, etc. This will need a dedicated function and layouting. ✅
45
46
  - Support uni- and bi-directional communication between graph object and plot object.🏗️
46
47
 
@@ -74,13 +74,15 @@ See <project:gallery/index.rst> for examples of plots made with `iplotx`. Feel f
74
74
  - compatibility with many GUI frameworks (e.g. Qt, GTK, Tkinter) thanks to `matplotlib`
75
75
  - data-driven axes autoscaling
76
76
  - consistent behaviour upon zooming and panning
77
- - correct HiDPI scaling (e.g. retina screens)
77
+ - correct HiDPI scaling (e.g. retina screens) including for vertex sizes, arrow sizes, and edge offsets
78
78
  - a consistent `matplotlib` artist hierarchy
79
79
  - post-plot editability (e.g. for animations)
80
80
  - plays well with other charting tools (e.g. `seaborn`)
81
81
  - chainable style contexts
82
82
  - vertex clusterings and covers with convex hulls and rounding
83
83
  - a plugin mechanism for additional libraries (WIP)
84
+ - animations (see <project:gallery/plot_animation.rst>)
85
+ - mouse/keyboard interaction and events (e.g. hover, click, see <project:gallery/plot_mouse_hover.rst>)
84
86
  - ... and probably more by the time you read this.
85
87
 
86
88
  ## Styles
@@ -6,7 +6,7 @@
6
6
 
7
7
  Computation times
8
8
  =================
9
- **00:01.429** total execution time for 32 files **from all galleries**:
9
+ **00:01.212** total execution time for 36 files **from all galleries**:
10
10
 
11
11
  .. container::
12
12
 
@@ -32,8 +32,11 @@ Computation times
32
32
  * - Example
33
33
  - Time
34
34
  - Mem (MB)
35
+ * - :ref:`sphx_glr_gallery_plot_ete4.py` (``../../gallery/plot_ete4.py``)
36
+ - 00:01.212
37
+ - 0.0
35
38
  * - :ref:`sphx_glr_gallery_plot_animation.py` (``../../gallery/plot_animation.py``)
36
- - 00:01.429
39
+ - 00:00.000
37
40
  - 0.0
38
41
  * - :ref:`sphx_glr_gallery_plot_basic.py` (``../../gallery/plot_basic.py``)
39
42
  - 00:00.000
@@ -56,6 +59,9 @@ Computation times
56
59
  * - :ref:`sphx_glr_gallery_plot_cogent3_tree.py` (``../../gallery/plot_cogent3_tree.py``)
57
60
  - 00:00.000
58
61
  - 0.0
62
+ * - :ref:`sphx_glr_gallery_plot_company_structure.py` (``../../gallery/plot_company_structure.py``)
63
+ - 00:00.000
64
+ - 0.0
59
65
  * - :ref:`sphx_glr_gallery_plot_complex.py` (``../../gallery/plot_complex.py``)
60
66
  - 00:00.000
61
67
  - 0.0
@@ -68,9 +74,6 @@ Computation times
68
74
  * - :ref:`sphx_glr_gallery_plot_edit_artists.py` (``../../gallery/plot_edit_artists.py``)
69
75
  - 00:00.000
70
76
  - 0.0
71
- * - :ref:`sphx_glr_gallery_plot_ete4.py` (``../../gallery/plot_ete4.py``)
72
- - 00:00.000
73
- - 0.0
74
77
  * - :ref:`sphx_glr_gallery_plot_four_grids.py` (``../../gallery/plot_four_grids.py``)
75
78
  - 00:00.000
76
79
  - 0.0
@@ -95,6 +98,9 @@ Computation times
95
98
  * - :ref:`sphx_glr_gallery_plot_minimum_spanning_trees.py` (``../../gallery/plot_minimum_spanning_trees.py``)
96
99
  - 00:00.000
97
100
  - 0.0
101
+ * - :ref:`sphx_glr_gallery_plot_mouse_hover.py` (``../../gallery/plot_mouse_hover.py``)
102
+ - 00:00.000
103
+ - 0.0
98
104
  * - :ref:`sphx_glr_gallery_plot_multipartite_layout.py` (``../../gallery/plot_multipartite_layout.py``)
99
105
  - 00:00.000
100
106
  - 0.0
@@ -122,6 +128,12 @@ Computation times
122
128
  * - :ref:`sphx_glr_gallery_plot_traveling_salesman.py` (``../../gallery/plot_traveling_salesman.py``)
123
129
  - 00:00.000
124
130
  - 0.0
131
+ * - :ref:`sphx_glr_gallery_plot_tree_node_background.py` (``../../gallery/plot_tree_node_background.py``)
132
+ - 00:00.000
133
+ - 0.0
134
+ * - :ref:`sphx_glr_gallery_plot_trees_of_trees.py` (``../../gallery/plot_trees_of_trees.py``)
135
+ - 00:00.000
136
+ - 0.0
125
137
  * - :ref:`sphx_glr_gallery_plot_voronoi.py` (``../../gallery/plot_voronoi.py``)
126
138
  - 00:00.000
127
139
  - 0.0
@@ -28,6 +28,7 @@ ipx.plotting.tree(
28
28
  # Moreover, the plot can be customised further using hmargin (horizontal label margin)
29
29
  # and some `matplotlib` settings.
30
30
 
31
+ # sphinx_gallery_thumbnail_number = 2
31
32
  leaf_labels = {leaf: f"Species {i+1}" for i, leaf in enumerate(tree.get_terminals())}
32
33
  fig, ax = plt.subplots(figsize=(4, 4))
33
34
  ipx.plotting.tree(
@@ -0,0 +1,72 @@
1
+ """
2
+ Company structure
3
+ =================
4
+
5
+ This example shows how to use `iplotx` to visualise simple logical relationships, for instance the organisational chart of a company.
6
+ """
7
+
8
+ import networkx as nx
9
+ import matplotlib.pyplot as plt
10
+ import iplotx as ipx
11
+
12
+ g = nx.DiGraph()
13
+ g.add_edges_from(
14
+ [
15
+ ("CEO", "Manager 1"),
16
+ ("CEO", "Manager 2"),
17
+ ("CEO", "Manager 3"),
18
+ ("Manager 1", "Employee 1"),
19
+ ("Manager 1", "Employee 2"),
20
+ ("Manager 2", "Employee 3"),
21
+ ("Manager 2", "Employee 4"),
22
+ ("Manager 3", "Employee 4"),
23
+ ]
24
+ )
25
+ layout = {
26
+ "CEO": [0, 0],
27
+ "Manager 1": [1, -1],
28
+ "Manager 2": [1, 0],
29
+ "Manager 3": [1, 1],
30
+ "Employee 1": [2, -1],
31
+ "Employee 2": [2, -0.5],
32
+ "Employee 3": [2, 0],
33
+ "Employee 4": [2, 0.5],
34
+ }
35
+ fig, ax = plt.subplots()
36
+ ipx.network(
37
+ g,
38
+ layout=layout,
39
+ ax=ax,
40
+ vertex_labels=True,
41
+ style="hollow",
42
+ vertex_marker="r",
43
+ edge_ports=[("e", "w")] * 8,
44
+ edge_curved=True,
45
+ edge_tension=[0.65] * 3 + [0.6] * 5,
46
+ margins=(0.08, 0.05),
47
+ )
48
+ # Show the layout top to bottom for clarity
49
+ ax.invert_yaxis()
50
+
51
+ # %%
52
+ # If you prefer a more squared look, you can use S-style waypoints with per-edge offsets:
53
+
54
+ fig, ax = plt.subplots()
55
+ ipx.network(
56
+ g,
57
+ layout=layout,
58
+ ax=ax,
59
+ vertex_labels=True,
60
+ style="hollow",
61
+ vertex_marker="r",
62
+ edge_ports=[("e", "w")] * 8,
63
+ edge_waypoints="xmidy0,xmidy1",
64
+ edge_offset=[(0, 0)] * 7 + [(0, -6)],
65
+ margins=(0.08, 0.05),
66
+ edge_linestyle=["-"] * 7 + ["--"],
67
+ )
68
+ ax.invert_yaxis()
69
+
70
+ # %%
71
+ # The `offset` edge style bypasses any layout coordinate system and acts in figure points directly.
72
+ # Combining edge offsets with noncartesian layout coordinate systems (e.g. `polar`) can lead to unexpected results.
@@ -33,6 +33,7 @@ artist = ipx.network(
33
33
  # %%
34
34
  # Now we can change the vertex sizes:
35
35
 
36
+ # sphinx_gallery_thumbnail_number = 2
36
37
  # SAME BLOCK AS BEFORE, ONLY NEEDED TO MAKE A NEW FIGURE
37
38
  artist = ipx.network(
38
39
  g,
@@ -21,19 +21,32 @@ ipx.plotting.tree(
21
21
 
22
22
  # %%
23
23
  # `iplotx` can compute a radial tree layout as well, and usual style modifications
24
- # work for trees same as networks:
24
+ # work for trees same as networks. Moreover, trees have a layout style option to
25
+ # choose the starting angle and angular span of the radial layout.
25
26
 
27
+ # sphinx_gallery_thumbnail_number = 2
26
28
  ipx.plotting.tree(
27
29
  tree,
28
30
  layout="radial",
31
+ orientation="right",
29
32
  style=[
30
33
  "tree",
31
34
  {
32
35
  "edge": {
33
- "color": "black",
36
+ "color": "deeppink",
34
37
  "linewidth": 4,
35
38
  },
39
+ "layout": {
40
+ "start": -180,
41
+ "span": 180,
42
+ },
43
+ "vertex": {
44
+ "label": {
45
+ "hmargin": 15,
46
+ }
47
+ },
36
48
  },
37
49
  ],
50
+ vertex_labels={leaf: str(i + 1) for i, leaf in enumerate(tree.leaves())},
38
51
  aspect=1,
39
52
  )
@@ -37,7 +37,7 @@ ipx.plot(
37
37
  },
38
38
  "edge": {
39
39
  "linestyle": linestyle,
40
- "offset": 0,
40
+ "paralleloffset": 0,
41
41
  "looptension": 3.5,
42
42
  "arrow": {
43
43
  "marker": "|>",
@@ -61,7 +61,7 @@ ipx.plot(
61
61
  vertex_edgecolor="none",
62
62
  vertex_label_color="black",
63
63
  edge_linestyle=linestyle,
64
- edge_offset=0,
64
+ edge_paralleloffset=0,
65
65
  edge_looptension=3.5,
66
66
  edge_arrow_marker="|>",
67
67
  ),
@@ -80,7 +80,7 @@ ipx.plot(
80
80
  vertex_edgecolor="none",
81
81
  vertex_label_color="black",
82
82
  edge_linestyle=linestyle,
83
- edge_offset=0,
83
+ edge_paralleloffset=0,
84
84
  edge_looptension=3.5,
85
85
  edge_arrow_marker="|>",
86
86
  )
@@ -94,7 +94,7 @@ with ipx.style.context(
94
94
  vertex_edgecolor="none",
95
95
  vertex_label_color="black",
96
96
  edge_linestyle=linestyle,
97
- edge_offset=0,
97
+ edge_paralleloffset=0,
98
98
  edge_looptension=3.5,
99
99
  edge_arrow_marker="|>",
100
100
  ):
@@ -0,0 +1,67 @@
1
+ """
2
+ Mouse event handling
3
+ ====================
4
+
5
+ This example shows how to interact with mouse events (e.g. hovering) in `iplotx`.
6
+
7
+ .. warning::
8
+ This example will run in a Python, IPython, or Jupyter session, however the
9
+ interactive functionality is not visible on the HTML page. Download the code
10
+ at the end of this page and run it in a local Python environment to see
11
+ the results.
12
+ """
13
+
14
+ import matplotlib.pyplot as plt
15
+ import numpy as np
16
+ import igraph as ig
17
+ import iplotx as ipx
18
+
19
+ g = ig.Graph.Ring(3, directed=True)
20
+
21
+ fig, ax = plt.subplots()
22
+ art = ipx.network(
23
+ g,
24
+ layout="circle",
25
+ ax=ax,
26
+ aspect=1,
27
+ )[0]
28
+ vertex_artist = art.get_vertices()
29
+
30
+ # Prepare an invisible annotation for hovering
31
+ annot = ax.annotate(
32
+ "",
33
+ xy=(0, 0),
34
+ xytext=(20, 20),
35
+ textcoords="offset points",
36
+ bbox=dict(boxstyle="round", fc=(0, 0, 0, 0.2)),
37
+ arrowprops=dict(arrowstyle="->"),
38
+ )
39
+ annot.set_visible(False)
40
+
41
+
42
+ def hover_callback(event):
43
+ """React to mouse hovering over vertices."""
44
+ if event.inaxes == ax:
45
+ vc = art.get_vertices()
46
+ cont, ind = vc.contains(event)
47
+ # If mouse is over a vertex, show the buble
48
+ if cont:
49
+ i = ind["ind"][0]
50
+ annot.xy = vc.get_offsets()[i]
51
+ annot.set_text(f"{i+1}")
52
+ annot.set_visible(True)
53
+ # Otherwise, hide the bubble
54
+ elif annot.get_visible():
55
+ annot.set_visible(False)
56
+ # If nothing changed, no need to redraw
57
+ else:
58
+ return
59
+
60
+ # Redraw to show/hide the bubble
61
+ fig.canvas.draw_idle()
62
+
63
+
64
+ fig.canvas.mpl_connect(
65
+ "motion_notify_event",
66
+ hover_callback,
67
+ )
@@ -10,12 +10,12 @@ import iplotx as ipx
10
10
 
11
11
  G = nx.path_graph(8)
12
12
  pos = nx.spring_layout(G, seed=47) # Seed layout for reproducibility
13
- ipx.plot(G, layout=pos)
13
+ ipx.network(G, layout=pos)
14
14
 
15
15
  # %%
16
16
  # We can change the color of the vertices and edges with a touch of style:
17
17
 
18
- ipx.plot(
18
+ ipx.network(
19
19
  G,
20
20
  layout=pos,
21
21
  style={
@@ -0,0 +1,55 @@
1
+ """
2
+ Tree cascades
3
+ =============
4
+
5
+ This example shows how to use `iplotx` to add cascading backgrounds to trees.
6
+ "Cascading" here means that each patch (rectangle/wedge/etc.) will cover a node
7
+ and all descendants, down to the leaves.
8
+ """
9
+
10
+ from Bio import Phylo
11
+ from io import StringIO
12
+ import matplotlib.pyplot as plt
13
+ import iplotx as ipx
14
+
15
+ # Make a tree from a string in Newick format
16
+ tree = next(
17
+ Phylo.NewickIO.parse(
18
+ StringIO(
19
+ "(()(()((()())(()()))))",
20
+ )
21
+ )
22
+ )
23
+
24
+ backgrounds = {
25
+ tree.get_nonterminals()[3]: "turquoise",
26
+ tree.get_terminals()[0]: "tomato",
27
+ tree.get_terminals()[1]: "purple",
28
+ }
29
+
30
+ ipx.plotting.tree(
31
+ tree,
32
+ vertex_cascade_facecolor=backgrounds,
33
+ )
34
+
35
+ # %%
36
+ # Cascading patches have a style option "extend" which affects whether the patches extend to the end of the deepest leaf:
37
+
38
+ ipx.plotting.tree(
39
+ tree,
40
+ layout="vertical",
41
+ vertex_cascade_facecolor=backgrounds,
42
+ vertex_cascade_extend=True,
43
+ )
44
+
45
+ # %%
46
+ # Cascading patches work with radial layouts as well:
47
+
48
+ # sphinx_gallery_thumbnail_number = 3
49
+ ipx.plotting.tree(
50
+ tree,
51
+ layout="radial",
52
+ vertex_cascade_facecolor=backgrounds,
53
+ vertex_cascade_extend=True,
54
+ aspect=1,
55
+ )
@@ -0,0 +1,83 @@
1
+ """
2
+ Tree of trees
3
+ =============
4
+
5
+ This example shows how to plot trees at the leaf of a tree, using the `iplotx` library.
6
+ Note that there are a few conceivable ways to do similar things as this in
7
+ `matplotlib` and this is just one such approach, using inset axes.
8
+ """
9
+
10
+ from ete4 import Tree
11
+ import matplotlib.pyplot as plt
12
+ import iplotx as ipx
13
+
14
+ tree = Tree(
15
+ "(,((),(((),()),((),()))));",
16
+ )
17
+ subtree_strings = [
18
+ "((a,b),(c,d));",
19
+ "(a,((b,c),d));",
20
+ "(a,b,c,d);",
21
+ "(a,(b,(c,d)));",
22
+ "(a,b);",
23
+ "(a,(b,c,d));",
24
+ ]
25
+
26
+ # Plot the initial tree
27
+ fig, ax = plt.subplots(figsize=(8, 5))
28
+ art = ipx.tree(
29
+ tree,
30
+ ax=ax,
31
+ aspect=1,
32
+ edge_color="grey",
33
+ )
34
+
35
+ for i, leaf in enumerate(tree.leaves()):
36
+
37
+ # Create an axis in the rough proximity
38
+ # and with the rough diemension of a leaf,
39
+ # with some padding
40
+ x, y = art.get_layout().T[leaf].values
41
+ subax = ax.inset_axes(
42
+ (x + 0.1, y - 0.4, 1.2, 0.8),
43
+ transform=ax.transData,
44
+ )
45
+
46
+ # For each leaf, make a tree
47
+ subtree = Tree(subtree_strings[i])
48
+ # Plot the tree with dashed lines
49
+ ipx.tree(
50
+ subtree,
51
+ ax=subax,
52
+ edge_linestyle="--",
53
+ )
54
+
55
+ # %%
56
+ # Combining this with other elements, e.g. cascading backgrounds, is possible too:
57
+
58
+ fig, ax = plt.subplots(figsize=(8, 5))
59
+ art = ipx.tree(
60
+ tree,
61
+ ax=ax,
62
+ aspect=1,
63
+ edge_color="grey",
64
+ vertex_cascade_facecolor={
65
+ list(tree.leaves())[0]: "lightblue",
66
+ list(tree.traverse("preorder"))[2]: "pink",
67
+ },
68
+ )
69
+ for i, leaf in enumerate(tree.leaves()):
70
+ x, y = art.get_layout().T[leaf].values
71
+ subax = ax.inset_axes(
72
+ (x + 0.1, y - 0.4, 1.2, 0.8),
73
+ transform=ax.transData,
74
+ )
75
+ # Set the inset axes background transparent
76
+ subax.patch.set_alpha(0)
77
+
78
+ subtree = Tree(subtree_strings[i])
79
+ ipx.tree(
80
+ subtree,
81
+ ax=subax,
82
+ edge_linestyle="--",
83
+ )