iplotx 0.2.0__tar.gz → 0.2.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 (132) hide show
  1. {iplotx-0.2.0 → iplotx-0.2.1}/PKG-INFO +15 -3
  2. {iplotx-0.2.0 → iplotx-0.2.1}/README.md +6 -2
  3. iplotx-0.2.1/assets/pylint.svg +23 -0
  4. {iplotx-0.2.0 → iplotx-0.2.1}/docs/source/conf.py +2 -0
  5. {iplotx-0.2.0 → iplotx-0.2.1}/docs/source/sg_execution_times.rst +9 -3
  6. iplotx-0.2.1/gallery/plot_animation.py +61 -0
  7. iplotx-0.2.1/gallery/plot_edit_artists.py +59 -0
  8. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/edge/__init__.py +160 -419
  9. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/edge/arrow.py +20 -20
  10. iplotx-0.2.1/iplotx/edge/geometry.py +392 -0
  11. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/edge/ports.py +7 -2
  12. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/groups.py +24 -14
  13. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/label.py +49 -14
  14. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/layout.py +3 -3
  15. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/network.py +9 -8
  16. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/style.py +18 -6
  17. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/tree.py +48 -21
  18. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/typing.py +19 -0
  19. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/version.py +1 -1
  20. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/vertex.py +84 -29
  21. {iplotx-0.2.0 → iplotx-0.2.1}/pyproject.toml +8 -0
  22. iplotx-0.2.1/scripts/update_pylint_badge.sh +12 -0
  23. {iplotx-0.2.0 → iplotx-0.2.1}/.github/workflows/publish.yml +0 -0
  24. {iplotx-0.2.0 → iplotx-0.2.1}/.github/workflows/test.yml +0 -0
  25. {iplotx-0.2.0 → iplotx-0.2.1}/.gitignore +0 -0
  26. {iplotx-0.2.0 → iplotx-0.2.1}/.readthedocs.yaml +0 -0
  27. {iplotx-0.2.0 → iplotx-0.2.1}/LICENSE +0 -0
  28. {iplotx-0.2.0 → iplotx-0.2.1}/MANIFEST.in +0 -0
  29. {iplotx-0.2.0 → iplotx-0.2.1}/docs/Makefile +0 -0
  30. {iplotx-0.2.0 → iplotx-0.2.1}/docs/make.bat +0 -0
  31. {iplotx-0.2.0 → iplotx-0.2.1}/docs/source/_static/graph_basic.png +0 -0
  32. {iplotx-0.2.0 → iplotx-0.2.1}/docs/source/_templates/layout.html +0 -0
  33. {iplotx-0.2.0 → iplotx-0.2.1}/docs/source/api.md +0 -0
  34. {iplotx-0.2.0 → iplotx-0.2.1}/docs/source/images/sphx_glr_plot_basic_001.png +0 -0
  35. {iplotx-0.2.0 → iplotx-0.2.1}/docs/source/images/thumb/sphx_glr_plot_basic_thumb.png +0 -0
  36. {iplotx-0.2.0 → iplotx-0.2.1}/docs/source/index.md +0 -0
  37. {iplotx-0.2.0 → iplotx-0.2.1}/docs/source/style.md +0 -0
  38. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/GALLERY_HEADER.rst +0 -0
  39. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/chess_masters_WCC.pgn.bz2 +0 -0
  40. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/knuth_miles.txt.gz +0 -0
  41. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_basic.py +0 -0
  42. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_big_curves.py +0 -0
  43. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_biopython_tree.py +0 -0
  44. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_chess_masters.py +0 -0
  45. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_cliques.py +0 -0
  46. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_cluster_layout.py +0 -0
  47. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_cogent3_tree.py +0 -0
  48. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_complex.py +0 -0
  49. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_dag.py +0 -0
  50. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_directed.py +0 -0
  51. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_ete4.py +0 -0
  52. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_four_grids.py +0 -0
  53. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_grouping.py +0 -0
  54. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_house.py +0 -0
  55. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_knuth_miles.py +0 -0
  56. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_labels_and_colors.py +0 -0
  57. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_loops.py +0 -0
  58. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_max_bipartite_matching.py +0 -0
  59. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_minimum_spanning_trees.py +0 -0
  60. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_multipartite_layout.py +0 -0
  61. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_parallel_igraph_networkx.py +0 -0
  62. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_ports.py +0 -0
  63. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_shortest_path.py +0 -0
  64. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_simple_networkx.py +0 -0
  65. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_simple_path.py +0 -0
  66. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_skbio_tree.py +0 -0
  67. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_style.py +0 -0
  68. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_traveling_salesman.py +0 -0
  69. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_voronoi.py +0 -0
  70. {iplotx-0.2.0 → iplotx-0.2.1}/gallery/plot_with_colorbar.py +0 -0
  71. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/__init__.py +0 -0
  72. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/ingest/__init__.py +0 -0
  73. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/ingest/heuristics.py +0 -0
  74. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/ingest/providers/network/igraph.py +0 -0
  75. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/ingest/providers/network/networkx.py +0 -0
  76. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/ingest/providers/tree/biopython.py +0 -0
  77. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/ingest/providers/tree/cogent3.py +0 -0
  78. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/ingest/providers/tree/ete4.py +0 -0
  79. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/ingest/providers/tree/skbio.py +0 -0
  80. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/ingest/typing.py +0 -0
  81. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/plotting.py +0 -0
  82. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/utils/geometry.py +0 -0
  83. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/utils/internal.py +0 -0
  84. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/utils/matplotlib.py +0 -0
  85. {iplotx-0.2.0 → iplotx-0.2.1}/iplotx/utils/style.py +0 -0
  86. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_biopython/leaf_labels.png +0 -0
  87. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_biopython/leaf_labels_hmargin.png +0 -0
  88. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_biopython/tree_basic.png +0 -0
  89. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_biopython/tree_radial.png +0 -0
  90. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_cogent3/leaf_labels.png +0 -0
  91. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_cogent3/leaf_labels_hmargin.png +0 -0
  92. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_cogent3/tree_basic.png +0 -0
  93. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_cogent3/tree_radial.png +0 -0
  94. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_ete4/leaf_labels.png +0 -0
  95. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_ete4/leaf_labels_hmargin.png +0 -0
  96. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_ete4/tree_basic.png +0 -0
  97. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_ete4/tree_radial.png +0 -0
  98. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/clustering_directed.png +0 -0
  99. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/clustering_directed_large.png +0 -0
  100. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/graph_basic.png +0 -0
  101. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/graph_directed.png +0 -0
  102. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/graph_directed_curved_loops.png +0 -0
  103. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/graph_edit_children.png +0 -0
  104. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/graph_labels.png +0 -0
  105. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/graph_layout_attribute.png +0 -0
  106. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/graph_null.png +0 -0
  107. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/graph_squares_directed.png +0 -0
  108. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/igraph_layout_object.png +0 -0
  109. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_igraph/multigraph_with_curved_edges_undirected.png +0 -0
  110. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_networkx/cluster-layout.png +0 -0
  111. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_networkx/complex.png +0 -0
  112. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_networkx/directed_graph.png +0 -0
  113. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_networkx/directed_graph_with_colorbar.png +0 -0
  114. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_networkx/empty_graph.png +0 -0
  115. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_networkx/flat_style.png +0 -0
  116. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_networkx/house_with_colors.png +0 -0
  117. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_networkx/labels_and_colors.png +0 -0
  118. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_networkx/shortest_path.png +0 -0
  119. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_networkx/simple_graph.png +0 -0
  120. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_skbio/leaf_labels.png +0 -0
  121. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_skbio/leaf_labels_hmargin.png +0 -0
  122. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_skbio/tree_basic.png +0 -0
  123. {iplotx-0.2.0 → iplotx-0.2.1}/tests/baseline_images/test_skbio/tree_radial.png +0 -0
  124. {iplotx-0.2.0 → iplotx-0.2.1}/tests/test_biopython.py +0 -0
  125. {iplotx-0.2.0 → iplotx-0.2.1}/tests/test_cogent3.py +0 -0
  126. {iplotx-0.2.0 → iplotx-0.2.1}/tests/test_ete4.py +0 -0
  127. {iplotx-0.2.0 → iplotx-0.2.1}/tests/test_igraph.py +0 -0
  128. {iplotx-0.2.0 → iplotx-0.2.1}/tests/test_networkx.py +0 -0
  129. {iplotx-0.2.0 → iplotx-0.2.1}/tests/test_skbio.py +0 -0
  130. {iplotx-0.2.0 → iplotx-0.2.1}/tests/test_style.py +0 -0
  131. {iplotx-0.2.0 → iplotx-0.2.1}/tests/utils.py +0 -0
  132. {iplotx-0.2.0 → iplotx-0.2.1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iplotx
3
- Version: 0.2.0
3
+ Version: 0.2.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
@@ -11,12 +11,20 @@ Author-email: Fabio Zanini <fabio.zanini@unsw.edu.au>
11
11
  Maintainer-email: Fabio Zanini <fabio.zanini@unsw.edu.au>
12
12
  License: MIT
13
13
  Keywords: graph,network,plotting,visualisation
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Education
17
+ Classifier: Intended Audience :: Science/Research
14
18
  Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Natural Language :: English
15
20
  Classifier: Operating System :: OS Independent
16
21
  Classifier: Programming Language :: Python :: 3
17
22
  Classifier: Programming Language :: Python :: 3.11
18
23
  Classifier: Programming Language :: Python :: 3.12
19
24
  Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Topic :: Scientific/Engineering :: Visualization
26
+ Classifier: Topic :: System :: Networking
27
+ Classifier: Typing :: Typed
20
28
  Requires-Python: >=3.11
21
29
  Requires-Dist: matplotlib>=2.0.0
22
30
  Requires-Dist: numpy>=2.0.0
@@ -31,11 +39,12 @@ Description-Content-Type: text/markdown
31
39
  ![Github Actions](https://github.com/fabilab/iplotx/actions/workflows/test.yml/badge.svg)
32
40
  ![PyPI - Version](https://img.shields.io/pypi/v/iplotx)
33
41
  ![RTD](https://readthedocs.org/projects/iplotx/badge/?version=latest)
42
+ ![pylint](assets/pylint.svg)
34
43
 
35
44
  # iplotx
36
45
  Plotting networks from igraph and networkx.
37
46
 
38
- **NOTE**: This is currently alpha quality software. The API and functionality will break constantly, so use at your own risk. That said, if you have things you would like to see improved, please open a GitHub issue.
47
+ **NOTE**: This is currently beta quality software. The API and functionality are settling in and might break occasionally.
39
48
 
40
49
  ## Installation
41
50
  ```bash
@@ -68,9 +77,12 @@ See [gallery](https://iplotx.readthedocs.io/en/latest/gallery/index.html).
68
77
  - Support storing the plot to disk thanks to the many matplotlib backends (SVG, PNG, PDF, etc.). ✅
69
78
  - Support flexible yet easy styling. ✅
70
79
  - Efficient plotting of large graphs using matplotlib's collection functionality. ✅
80
+ - Support editing plotting elements after the plot is created, e.g. changing node colors, labels, etc. ✅
81
+ - Support animations, e.g. showing the evolution of a network over time. ✅
71
82
  - Support trees from special libraries such as ete3, biopython, etc. This will need a dedicated function and layouting. ✅
72
- - Support animations, e.g. showing the evolution of a network over time. 🏗️
73
83
  - Support uni- and bi-directional communication between graph object and plot object.🏗️
74
84
 
85
+ **NOTE:** The last item can probably be achieved already by using `matplotlib`'s existing callback functionality. It is currently untested, but if you manage to get it to work on your graph let me know and I'll add it to the examples (with credit).
86
+
75
87
  ## Authors
76
88
  Fabio Zanini (https://fabilab.org)
@@ -1,11 +1,12 @@
1
1
  ![Github Actions](https://github.com/fabilab/iplotx/actions/workflows/test.yml/badge.svg)
2
2
  ![PyPI - Version](https://img.shields.io/pypi/v/iplotx)
3
3
  ![RTD](https://readthedocs.org/projects/iplotx/badge/?version=latest)
4
+ ![pylint](assets/pylint.svg)
4
5
 
5
6
  # iplotx
6
7
  Plotting networks from igraph and networkx.
7
8
 
8
- **NOTE**: This is currently alpha quality software. The API and functionality will break constantly, so use at your own risk. That said, if you have things you would like to see improved, please open a GitHub issue.
9
+ **NOTE**: This is currently beta quality software. The API and functionality are settling in and might break occasionally.
9
10
 
10
11
  ## Installation
11
12
  ```bash
@@ -38,9 +39,12 @@ See [gallery](https://iplotx.readthedocs.io/en/latest/gallery/index.html).
38
39
  - Support storing the plot to disk thanks to the many matplotlib backends (SVG, PNG, PDF, etc.). ✅
39
40
  - Support flexible yet easy styling. ✅
40
41
  - Efficient plotting of large graphs using matplotlib's collection functionality. ✅
42
+ - Support editing plotting elements after the plot is created, e.g. changing node colors, labels, etc. ✅
43
+ - Support animations, e.g. showing the evolution of a network over time. ✅
41
44
  - Support trees from special libraries such as ete3, biopython, etc. This will need a dedicated function and layouting. ✅
42
- - Support animations, e.g. showing the evolution of a network over time. 🏗️
43
45
  - Support uni- and bi-directional communication between graph object and plot object.🏗️
44
46
 
47
+ **NOTE:** The last item can probably be achieved already by using `matplotlib`'s existing callback functionality. It is currently untested, but if you manage to get it to work on your graph let me know and I'll add it to the examples (with credit).
48
+
45
49
  ## Authors
46
50
  Fabio Zanini (https://fabilab.org)
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="20">
3
+ <linearGradient id="b" x2="0" y2="100%">
4
+ <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
5
+ <stop offset="1" stop-opacity=".1"/>
6
+ </linearGradient>
7
+ <mask id="anybadge_1">
8
+ <rect width="80" height="20" rx="3" fill="#fff"/>
9
+ </mask>
10
+ <g mask="url(#anybadge_1)">
11
+ <path fill="#555" d="M0 0h44v20H0z"/>
12
+ <path fill="#4C1" d="M44 0h36v20H44z"/>
13
+ <path fill="url(#b)" d="M0 0h80v20H0z"/>
14
+ </g>
15
+ <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
16
+ <text x="23.0" y="15" fill="#010101" fill-opacity=".3">pylint</text>
17
+ <text x="22.0" y="14">pylint</text>
18
+ </g>
19
+ <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
20
+ <text x="63.0" y="15" fill="#010101" fill-opacity=".3">9.13</text>
21
+ <text x="62.0" y="14">9.13</text>
22
+ </g>
23
+ </svg>
@@ -49,6 +49,8 @@ myst_enable_extensions = ["colon_fence"]
49
49
  sphinx_gallery_conf = {
50
50
  "examples_dirs": "../../gallery", # path to your example scripts
51
51
  "gallery_dirs": "./gallery", # path to where to save gallery generated output
52
+ #'matplotlib_animations': (True, 'mp4'),
53
+ "matplotlib_animations": True,
52
54
  }
53
55
 
54
56
  source_suffix = {
@@ -6,7 +6,7 @@
6
6
 
7
7
  Computation times
8
8
  =================
9
- **00:00.061** total execution time for 30 files **from all galleries**:
9
+ **00:01.429** total execution time for 32 files **from all galleries**:
10
10
 
11
11
  .. container::
12
12
 
@@ -32,8 +32,8 @@ Computation times
32
32
  * - Example
33
33
  - Time
34
34
  - Mem (MB)
35
- * - :ref:`sphx_glr_gallery_plot_ports.py` (``../../gallery/plot_ports.py``)
36
- - 00:00.061
35
+ * - :ref:`sphx_glr_gallery_plot_animation.py` (``../../gallery/plot_animation.py``)
36
+ - 00:01.429
37
37
  - 0.0
38
38
  * - :ref:`sphx_glr_gallery_plot_basic.py` (``../../gallery/plot_basic.py``)
39
39
  - 00:00.000
@@ -65,6 +65,9 @@ Computation times
65
65
  * - :ref:`sphx_glr_gallery_plot_directed.py` (``../../gallery/plot_directed.py``)
66
66
  - 00:00.000
67
67
  - 0.0
68
+ * - :ref:`sphx_glr_gallery_plot_edit_artists.py` (``../../gallery/plot_edit_artists.py``)
69
+ - 00:00.000
70
+ - 0.0
68
71
  * - :ref:`sphx_glr_gallery_plot_ete4.py` (``../../gallery/plot_ete4.py``)
69
72
  - 00:00.000
70
73
  - 0.0
@@ -98,6 +101,9 @@ Computation times
98
101
  * - :ref:`sphx_glr_gallery_plot_parallel_igraph_networkx.py` (``../../gallery/plot_parallel_igraph_networkx.py``)
99
102
  - 00:00.000
100
103
  - 0.0
104
+ * - :ref:`sphx_glr_gallery_plot_ports.py` (``../../gallery/plot_ports.py``)
105
+ - 00:00.000
106
+ - 0.0
101
107
  * - :ref:`sphx_glr_gallery_plot_shortest_path.py` (``../../gallery/plot_shortest_path.py``)
102
108
  - 00:00.000
103
109
  - 0.0
@@ -0,0 +1,61 @@
1
+ """
2
+ Animations
3
+ ==========
4
+
5
+ This tutorial shows how to animate `iplotx` visualizations using `matplotlib.animation.FuncAnimation`.
6
+
7
+ For illustration purposes, we will animate a simple directed graph, rotating it around its center. We also modify the opacity of the vertices and edges, just for fun.
8
+ """
9
+
10
+ import matplotlib.pyplot as plt
11
+ import numpy as np
12
+ import matplotlib.animation as animation
13
+ import igraph as ig
14
+ import iplotx as ipx
15
+
16
+ g = ig.Graph.Ring(3, directed=True)
17
+ layout = np.asarray(g.layout("circle").coords)
18
+
19
+ # The animation will rotate the layout of the graph
20
+ thetas = np.linspace(0, 2 * np.pi, 101)[:-1]
21
+
22
+ fig, ax = plt.subplots()
23
+ art = ipx.network(g, ax=ax, layout=layout, aspect=1)[0]
24
+ ax.set(xlim=[-2, 2], ylim=[-2, 2])
25
+
26
+
27
+ def rotate(vector, theta):
28
+ """Rotate a 2D vector by an angle theta (in radians) clockwise."""
29
+ return vector @ np.array(
30
+ [
31
+ [np.cos(theta), -np.sin(theta)],
32
+ [np.sin(theta), np.cos(theta)],
33
+ ],
34
+ )
35
+
36
+
37
+ def update(frame):
38
+ # for each frame, update the vertex positions
39
+ theta = thetas[frame]
40
+
41
+ # The new layout is the old layout rotated by theta, clockwise
42
+ layout_new = rotate(layout, theta)
43
+
44
+ # Also change transparency, slower
45
+ alpha_vertices = 1 - np.abs(np.sin(theta / 2))
46
+ alpha_edges = 0.25 + 0.75 * np.abs(np.sin(theta / 2))
47
+
48
+ # Edit the vertices' positions
49
+ art.get_vertices().set_offsets(layout_new)
50
+ art.get_vertices().set_alpha(alpha_vertices)
51
+ art.get_edges().set_alpha(alpha_edges)
52
+ return (art.get_vertices(), art.get_edges())
53
+
54
+
55
+ # Run the animation
56
+ ani = animation.FuncAnimation(
57
+ fig=fig,
58
+ func=update,
59
+ frames=len(thetas),
60
+ interval=30,
61
+ )
@@ -0,0 +1,59 @@
1
+ """
2
+ Editing artists after plotting
3
+ ==============================
4
+
5
+ One of the strengths of `iplotx` is the support for editing artists after they have been plotted the first time without making a whole new figure.
6
+
7
+ In this example, we will change vertices, edges, arrows, etc. and check out how they look like.
8
+ """
9
+
10
+ # %%
11
+ # This is the vanilla version, taken from the "Ports" gallery example:
12
+
13
+ import igraph as ig
14
+ import numpy as np
15
+ import matplotlib.pyplot as plt
16
+ import iplotx as ipx
17
+
18
+ g = ig.Graph.Ring(3, directed=True)
19
+
20
+ artist = ipx.network(
21
+ g,
22
+ layout="circle",
23
+ edge_curved=True,
24
+ edge_ports=[
25
+ ("n", "w"), # exit from the top, enter from the left
26
+ ("e", "s"), # exit from the right, enter from the bottom
27
+ ("n", "s"), # exit from the top, enter from the bottom
28
+ ],
29
+ edge_tension=[1.5, 1.8, 0.8],
30
+ edge_color=["tomato", "steelblue", "purple"],
31
+ )[0]
32
+
33
+ # %%
34
+ # Now we can change the vertex sizes:
35
+
36
+ # SAME BLOCK AS BEFORE, ONLY NEEDED TO MAKE A NEW FIGURE
37
+ artist = ipx.network(
38
+ g,
39
+ layout="circle",
40
+ edge_curved=True,
41
+ edge_ports=[
42
+ ("n", "w"), # exit from the top, enter from the left
43
+ ("e", "s"), # exit from the right, enter from the bottom
44
+ ("n", "s"), # exit from the top, enter from the bottom
45
+ ],
46
+ edge_tension=[1.5, 1.8, 0.8],
47
+ edge_color=["tomato", "steelblue", "purple"],
48
+ )[0]
49
+ # END OF SAME BLOCK
50
+
51
+ artist.get_vertices().set_sizes([5, 5, 40])
52
+ artist.get_edges().set_ports(
53
+ [
54
+ ("n", "n"),
55
+ ("w", None),
56
+ ("e", "s"),
57
+ ]
58
+ )
59
+ artist.get_edges().set_tension([1.3, 0.3, 0.5])