iplotx 0.1.0__py3-none-any.whl → 0.2.1__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/styles.py DELETED
@@ -1,186 +0,0 @@
1
- from typing import Union, Sequence, Hashable
2
- from copy import deepcopy
3
- from contextlib import contextmanager
4
- import numpy as np
5
- import pandas as pd
6
-
7
-
8
- style_leaves = (
9
- "edgecolor",
10
- "facecolor",
11
- "linewidth",
12
- "linestyle",
13
- "alpha",
14
- "zorder",
15
- )
16
-
17
-
18
- default = {
19
- "vertex": {
20
- "size": 20,
21
- "facecolor": "black",
22
- "marker": "o",
23
- "label": {
24
- "horizontalalignment": "center",
25
- "verticalalignment": "center",
26
- "hpadding": 18,
27
- "vpadding": 12,
28
- },
29
- },
30
- "edge": {
31
- "linewidth": 1.5,
32
- "linestyle": "-",
33
- "color": "black",
34
- "curved": False,
35
- "offset": 3,
36
- "tension": 1,
37
- "label": {
38
- "horizontalalignment": "center",
39
- "verticalalignment": "center",
40
- },
41
- },
42
- "arrow": {
43
- "marker": "|>",
44
- "width": 8,
45
- "color": "black",
46
- },
47
- "grouping": {
48
- "facecolor": ["grey", "steelblue", "tomato"],
49
- "edgecolor": "black",
50
- "linewidth": 1.5,
51
- "alpha": 0.5,
52
- "vertexpadding": 25,
53
- },
54
- }
55
-
56
- hollow = deepcopy(default)
57
- hollow["vertex"]["color"] = None
58
- hollow["vertex"]["facecolor"] = "none"
59
- hollow["vertex"]["edgecolor"] = "black"
60
- hollow["vertex"]["linewidth"] = 1.5
61
- hollow["vertex"]["marker"] = "r"
62
- hollow["vertex"]["size"] = "label"
63
-
64
-
65
- styles = {
66
- "default": default,
67
- "hollow": hollow,
68
- }
69
-
70
-
71
- stylename = "default"
72
-
73
-
74
- current = deepcopy(styles["default"])
75
-
76
-
77
- def get_stylename():
78
- """Return the name of the current iplotx style."""
79
- return str(stylename)
80
-
81
-
82
- def get_style(name: str = ""):
83
- namelist = name.split(".")
84
- style = styles
85
- for i, namei in enumerate(namelist):
86
- if (i == 0) and (namei == ""):
87
- style = current
88
- else:
89
- try:
90
- style = style[namei]
91
- except KeyError:
92
- raise KeyError(f"Style not found: {name}")
93
-
94
- style = deepcopy(style)
95
- return style
96
-
97
-
98
- # The following is inspired by matplotlib's style library
99
- # https://github.com/matplotlib/matplotlib/blob/v3.10.3/lib/matplotlib/style/core.py#L45
100
- def use(style: Union[str, dict, Sequence]):
101
- """Use iplotx style setting for a style specification.
102
-
103
- The style name of 'default' is reserved for reverting back to
104
- the default style settings.
105
-
106
- Parameters:
107
- style: A style specification, currently either a name of an existing style
108
- or a dict with specific parts of the style to override. The string
109
- "default" resets the style to the default one. If this is a sequence,
110
- each style is applied in order.
111
- """
112
- global current
113
-
114
- def _update(style: dict, current: dict):
115
- for key, value in style.items():
116
- if key not in current:
117
- current[key] = value
118
- continue
119
-
120
- # Style leaves are by definition not to be recurred into
121
- if isinstance(value, dict) and (key not in style_leaves):
122
- _update(value, current[key])
123
- elif value is None:
124
- del current[key]
125
- else:
126
- current[key] = value
127
-
128
- if isinstance(style, (dict, str)):
129
- styles = [style]
130
- else:
131
- styles = style
132
-
133
- for style in styles:
134
- if style == "default":
135
- reset()
136
- else:
137
- if isinstance(style, str):
138
- current = get_style(style)
139
- else:
140
- _update(style, current)
141
-
142
-
143
- def reset():
144
- """Reset to default style."""
145
- global current
146
- current = deepcopy(styles["default"])
147
-
148
-
149
- @contextmanager
150
- def stylecontext(style: Union[str, dict, Sequence]):
151
- current = get_style()
152
- try:
153
- use(style)
154
- yield
155
- finally:
156
- use(current)
157
-
158
-
159
- def rotate_style(
160
- style,
161
- index: Union[int, None] = None,
162
- id: Union[Hashable, None] = None,
163
- props=style_leaves,
164
- ):
165
- if (index is None) and (id is None):
166
- raise ValueError(
167
- "At least one of 'index' or 'id' must be provided to rotate_style."
168
- )
169
-
170
- style = deepcopy(style)
171
-
172
- for prop in props:
173
- val = style.get(prop, None)
174
- if val is None:
175
- continue
176
- # NOTE: this assumes that these properties are leaves of the style tree
177
- # Btw: dict includes defaultdict, Couter, etc.
178
- if (id is not None) and isinstance(val, (dict, pd.Series)):
179
- # This works on both dict-like and Series
180
- style[prop] = val[id]
181
- elif (index is not None) and isinstance(
182
- val, (tuple, list, np.ndarray, pd.Index, pd.Series)
183
- ):
184
- style[prop] = np.asarray(val)[index % len(val)]
185
-
186
- return style
@@ -1,47 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: iplotx
3
- Version: 0.1.0
4
- Summary: Plot networkx from igraph and networkx.
5
- Project-URL: Homepage, https://github.com/fabilab/iplotx
6
- Project-URL: Documentation, https://readthedocs.org/iplotx
7
- Project-URL: Repository, https://github.com/fabilab/iplotx.git
8
- Project-URL: Bug Tracker, https://github.com/fabilab/iplotx/issues
9
- Project-URL: Changelog, https://github.com/fabilab/iplotx/blob/main/CHANGELOG.md
10
- Author-email: Fabio Zanini <fabio.zanini@unsw.edu.au>
11
- Maintainer-email: Fabio Zanini <fabio.zanini@unsw.edu.au>
12
- License: MIT
13
- Keywords: graph,network,plotting,visualisation
14
- Classifier: License :: OSI Approved :: MIT License
15
- Classifier: Operating System :: OS Independent
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.8
18
- Classifier: Programming Language :: Python :: 3.9
19
- Classifier: Programming Language :: Python :: 3.10
20
- Classifier: Programming Language :: Python :: 3.11
21
- Requires-Python: >=3.10
22
- Requires-Dist: matplotlib>=2.0.0
23
- Requires-Dist: pandas>=2.0.0
24
- Provides-Extra: igraph
25
- Requires-Dist: igraph>=0.11.0; extra == 'igraph'
26
- Provides-Extra: networkx
27
- Requires-Dist: networkx>=2.0.0; extra == 'networkx'
28
- Description-Content-Type: text/markdown
29
-
30
- ![Github Actions](https://github.com/fabilab/iplotx/actions/workflows/test.yml/badge.svg)
31
- ![PyPI - Version](https://img.shields.io/pypi/v/iplotx)
32
-
33
- # iplotx
34
- Plotting networks from igraph and networkx.
35
-
36
- **NOTE**: This is currently pre-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.
37
-
38
- ## Roadmap
39
- - Plot networks from igraph and networkx interchangeably, using matplotlib as a backend. ✅
40
- - Support interactive plotting, e.g. zooming and panning after the plot is created. ✅
41
- - Support storing the plot to disk thanks to the many matplotlib backends (SVG, PNG, PDF, etc.).
42
- - Efficient plotting of large graphs using matplotlib's collection functionality. ✅ (partially)
43
- - Support animations, e.g. showing the evolution of a network over time. 🏗️
44
- - Support uni- and bi-directional communication between graph object and plot object.🏗️
45
-
46
- ## Authors
47
- Fabio Zanini (https://fabilab.org)
@@ -1,20 +0,0 @@
1
- iplotx/__init__.py,sha256=VrbOJwPlhb_wEeyCU0OcfiNde_SJqYmHwa1Qh2trHvE,60
2
- iplotx/groups.py,sha256=PplZgemEEg7b285fwV--08yIIomRTgg0xxyvvHeoBp8,4289
3
- iplotx/heuristics.py,sha256=bnfetQRxZA-Ii2V61XH7VYnvvG6DyKqiH2iOsA5la9o,3810
4
- iplotx/importing.py,sha256=GCzbQ4X8BAk0Cv9Nue-B-3vHiCmGHmF6pVPIVRUhGI8,267
5
- iplotx/network.py,sha256=jipKjV6NtVteUoqeSTRc1kfkmRfTT0L8uEPCLt_ipJ4,18070
6
- iplotx/plotting.py,sha256=wyPrDPMNscuiCdO0Md--ZSU6_uJ3XnCTJg8yKIYnm5g,3481
7
- iplotx/styles.py,sha256=lHn-NRQ0CkG7dWe-J1wuGa-rH8ut4dqBa8rLGbqk1Ig,4679
8
- iplotx/typing.py,sha256=0RrZqEKsC9rSnPQIKg-br1g2w5wDVpTzrlx04rKnN0Y,1304
9
- iplotx/version.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
10
- iplotx/vertex.py,sha256=qP6V9eAoC6zb9uD00sxUlIWnEPbMxLeQRJoiKVCubLU,3485
11
- iplotx/edge/arrow.py,sha256=gUvTXVFG8e9G0qeztljqHVTZwYSCrhIDj0HGq3anenk,3876
12
- iplotx/edge/common.py,sha256=62CCsA_1z9qhKIgSEbnfxzj9elKxPDv0REbLewKnnqo,1445
13
- iplotx/edge/directed.py,sha256=zUU0vJApasNcvIApNGYy_x0NDnVyStgCKJn5J6U3tW4,5059
14
- iplotx/edge/label.py,sha256=rutePN_WEIT8IR7FSRrvsoIJw2WoFWDSHCh0dmHeJTI,1407
15
- iplotx/edge/undirected.py,sha256=LfDHqUP5zEBuf69lyOhUU_tk5ZGCJyw5xL3eZnTk7OU,14799
16
- iplotx/utils/geometry.py,sha256=3HIsH_Nek_m41vL7twvgmDYfhlJURYd5TbMaa15nyt8,7804
17
- iplotx/utils/matplotlib.py,sha256=I4Lw6vMPIgKMyqcR6RQBiRPKnmi5ko_GAtG04cT5XPw,3972
18
- iplotx-0.1.0.dist-info/METADATA,sha256=UMVggqiCw-xHPHY7s5ACPBnjIeWLl-COy01CjB0MEyw,2252
19
- iplotx-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
20
- iplotx-0.1.0.dist-info/RECORD,,
File without changes