hiveplotlib 0.24.0__tar.gz → 0.25.0__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 (31) hide show
  1. {hiveplotlib-0.24.0/src/hiveplotlib.egg-info → hiveplotlib-0.25.0}/PKG-INFO +24 -2
  2. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/README.md +15 -1
  3. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/pyproject.toml +14 -5
  4. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/converters.py +0 -1
  5. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/datasets/__init__.py +51 -2
  6. hiveplotlib-0.25.0/src/hiveplotlib/viz/base.py +165 -0
  7. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/viz/bokeh.py +15 -49
  8. hiveplotlib-0.25.0/src/hiveplotlib/viz/holoviews.py +717 -0
  9. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/viz/input_checks.py +1 -1
  10. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/viz/matplotlib.py +16 -55
  11. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/viz/plotly.py +20 -47
  12. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0/src/hiveplotlib.egg-info}/PKG-INFO +24 -2
  13. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib.egg-info/SOURCES.txt +1 -0
  14. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib.egg-info/requires.txt +9 -0
  15. hiveplotlib-0.24.0/src/hiveplotlib/viz/base.py +0 -62
  16. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/LICENSE +0 -0
  17. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/MANIFEST.in +0 -0
  18. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/setup.cfg +0 -0
  19. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/setup.py +0 -0
  20. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/__init__.py +0 -0
  21. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/axis.py +0 -0
  22. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/datasets/trade_data_harvard_growth_lab/international_exports_2019_8112.csv +0 -0
  23. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/datasets/trade_data_harvard_growth_lab/international_exports_metadata_2019_8112.json +0 -0
  24. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/hiveplot.py +0 -0
  25. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/node.py +0 -0
  26. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/p2cp.py +0 -0
  27. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/utils.py +0 -0
  28. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/viz/__init__.py +0 -0
  29. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib/viz/datashader.py +0 -0
  30. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib.egg-info/dependency_links.txt +0 -0
  31. {hiveplotlib-0.24.0 → hiveplotlib-0.25.0}/src/hiveplotlib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hiveplotlib
3
- Version: 0.24.0
3
+ Version: 0.25.0
4
4
  Summary: Visualize Network Data with Hive Plots
5
5
  Author-email: Gary Koplik <gary.koplik@geomdata.com>
6
6
  License: Copyright (c) 2020 - 2023, Geometric Data Analytics, Inc.
@@ -41,14 +41,20 @@ Requires-Dist: pandas
41
41
  Provides-Extra: bokeh
42
42
  Requires-Dist: bokeh; extra == "bokeh"
43
43
  Provides-Extra: datashader
44
+ Requires-Dist: dask[dataframe]; extra == "datashader"
44
45
  Requires-Dist: datashader; extra == "datashader"
45
46
  Requires-Dist: seaborn; extra == "datashader"
46
47
  Provides-Extra: dev
47
48
  Requires-Dist: bokeh; extra == "dev"
49
+ Requires-Dist: cartopy; extra == "dev"
48
50
  Requires-Dist: datashader; extra == "dev"
51
+ Requires-Dist: geopandas; extra == "dev"
49
52
  Requires-Dist: flexitext; extra == "dev"
53
+ Requires-Dist: holoviews; extra == "dev"
50
54
  Requires-Dist: jupyter; extra == "dev"
51
55
  Requires-Dist: networkx; extra == "dev"
56
+ Requires-Dist: plotly; extra == "dev"
57
+ Requires-Dist: pybadges; extra == "dev"
52
58
  Requires-Dist: seaborn; extra == "dev"
53
59
  Requires-Dist: tqdm; extra == "dev"
54
60
  Provides-Extra: docs
@@ -56,6 +62,8 @@ Requires-Dist: nbsphinx; extra == "docs"
56
62
  Requires-Dist: sphinx; extra == "docs"
57
63
  Requires-Dist: sphinx-rtd-theme; extra == "docs"
58
64
  Requires-Dist: toml; extra == "docs"
65
+ Provides-Extra: holoviews
66
+ Requires-Dist: holoviews; extra == "holoviews"
59
67
  Provides-Extra: networkx
60
68
  Requires-Dist: networkx; extra == "networkx"
61
69
  Provides-Extra: plotly
@@ -73,7 +81,13 @@ Requires-Dist: pytest-xdist; extra == "testing"
73
81
 
74
82
  A plotting package for generating and visualizing static Hive Plots in `matplotlib`.
75
83
 
76
- <br>
84
+ ![](https://gitlab.com/geomdata/hiveplotlib/-/raw/22-add-formal-holoviews-support/.gitlab/python_badge.svg)
85
+
86
+ [![](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/matplotlib_badge.svg)](https://matplotlib.org/)
87
+ [![](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/bokeh_badge.svg)](https://docs.bokeh.org/en/latest/)
88
+ [![](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/holoviews_badge.svg)](https://holoviews.org/index.html)
89
+ [![](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/plotly_badge.svg)](https://plotly.com/python/)
90
+ [![](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/datashader_badge.svg)](https://datashader.org/)
77
91
 
78
92
  # Installation
79
93
 
@@ -89,6 +103,14 @@ To uninstall, run:
89
103
  $ pip uninstall hiveplotlib
90
104
  ```
91
105
 
106
+ By default, `hiveplotlib` supports visualization only with the [matplotlib](https://matplotlib.org/) backend, but
107
+ `hiveplotlib` also supports [bokeh](https://docs.bokeh.org/en/latest/), [holoviews](https://holoviews.org/index.html),
108
+ and [plotly](https://plotly.com/python/) visualizations, which can be installed via `pip install hiveplotlib[bokeh]`,
109
+ `pip install hiveplotlib[holoviews]`, and `pip install hiveplotlib[plotly]`, respectively.
110
+
111
+ `hiveplotlib` also supports large network visualization via the [datashader](https://datashader.org/) backend,
112
+ which can be installed as `pip install hiveplotlib[datashader]`.
113
+
92
114
  # Contributing
93
115
 
94
116
  For more on contributing to the project, see [CONTRIBUTING.md](https://gitlab.com/geomdata/hiveplotlib/-/blob/master/CONTRIBUTING.md)
@@ -2,7 +2,13 @@
2
2
 
3
3
  A plotting package for generating and visualizing static Hive Plots in `matplotlib`.
4
4
 
5
- <br>
5
+ ![](https://gitlab.com/geomdata/hiveplotlib/-/raw/22-add-formal-holoviews-support/.gitlab/python_badge.svg)
6
+
7
+ [![](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/matplotlib_badge.svg)](https://matplotlib.org/)
8
+ [![](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/bokeh_badge.svg)](https://docs.bokeh.org/en/latest/)
9
+ [![](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/holoviews_badge.svg)](https://holoviews.org/index.html)
10
+ [![](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/plotly_badge.svg)](https://plotly.com/python/)
11
+ [![](https://gitlab.com/geomdata/hiveplotlib/-/raw/master/.gitlab/datashader_badge.svg)](https://datashader.org/)
6
12
 
7
13
  # Installation
8
14
 
@@ -18,6 +24,14 @@ To uninstall, run:
18
24
  $ pip uninstall hiveplotlib
19
25
  ```
20
26
 
27
+ By default, `hiveplotlib` supports visualization only with the [matplotlib](https://matplotlib.org/) backend, but
28
+ `hiveplotlib` also supports [bokeh](https://docs.bokeh.org/en/latest/), [holoviews](https://holoviews.org/index.html),
29
+ and [plotly](https://plotly.com/python/) visualizations, which can be installed via `pip install hiveplotlib[bokeh]`,
30
+ `pip install hiveplotlib[holoviews]`, and `pip install hiveplotlib[plotly]`, respectively.
31
+
32
+ `hiveplotlib` also supports large network visualization via the [datashader](https://datashader.org/) backend,
33
+ which can be installed as `pip install hiveplotlib[datashader]`.
34
+
21
35
  # Contributing
22
36
 
23
37
  For more on contributing to the project, see [CONTRIBUTING.md](https://gitlab.com/geomdata/hiveplotlib/-/blob/master/CONTRIBUTING.md)
@@ -1,13 +1,12 @@
1
1
  [build-system]
2
2
  requires = [
3
3
  "setuptools",
4
- "wheel"
5
4
  ]
6
5
  build-backend = "setuptools.build_meta"
7
6
 
8
7
  [project]
9
8
  name = "hiveplotlib"
10
- version = "0.24.0"
9
+ version = "0.25.0"
11
10
  authors = [
12
11
  {name="Gary Koplik", email="gary.koplik@geomdata.com"}
13
12
  ]
@@ -30,6 +29,7 @@ bokeh = [
30
29
  ]
31
30
 
32
31
  datashader = [
32
+ "dask[dataframe]", # https://github.com/holoviz/datashader/issues/1319
33
33
  "datashader",
34
34
  "seaborn"
35
35
  ]
@@ -37,10 +37,15 @@ datashader = [
37
37
  # developer dependencies
38
38
  dev = [
39
39
  "bokeh",
40
+ "cartopy",
40
41
  "datashader",
42
+ "geopandas",
41
43
  "flexitext",
44
+ "holoviews",
42
45
  "jupyter",
43
46
  "networkx",
47
+ "plotly",
48
+ "pybadges",
44
49
  "seaborn",
45
50
  "tqdm",
46
51
  ]
@@ -53,6 +58,10 @@ docs = [
53
58
  "toml"
54
59
  ]
55
60
 
61
+ holoviews = [
62
+ "holoviews"
63
+ ]
64
+
56
65
  networkx = [
57
66
  "networkx"
58
67
  ]
@@ -98,11 +107,11 @@ target-version = "py311"
98
107
 
99
108
  [tool.ruff.lint]
100
109
  extend-ignore = [
101
- "ANN101", # typing `self` being deprecated (and not particularly useful)
102
- "ANN003", # don't require type hints on kwargs (too many possible types to be useful)
110
+ "ANN101", # typing `self` being deprecated (and not particularly useful)
111
+ "ANN003", # don't require type hints on kwargs (too many possible types to be useful)
103
112
  "D200", # 1-line docstrings will be tolerated
104
113
  "D203", # don't require blank line before class docstring.
105
- "D212", # require Docstring text starts on the next line after the triple quotes.
114
+ "D212", # require docstring text starts on the next line after the triple quotes.
106
115
  "E203", # https://black.readthedocs.io/en/stable/faq.html#why-are-flake8-s-e203-and-w503-violated
107
116
  "PD901", # generic `df` name for pandas dataframes will be tolerated
108
117
  ]
@@ -4,7 +4,6 @@
4
4
  Converters from various data structures to ``hiveplotlib``-ready structures.
5
5
  """
6
6
 
7
-
8
7
  from typing import List, Tuple
9
8
 
10
9
  import numpy as np
@@ -23,7 +23,7 @@ from typing import Dict, Hashable, List, Optional, Tuple, Union
23
23
  import numpy as np
24
24
  import pandas as pd
25
25
 
26
- from hiveplotlib import HivePlot, Node, hive_plot_n_axes
26
+ from hiveplotlib import P2CP, HivePlot, Node, hive_plot_n_axes, p2cp_n_axes
27
27
  from hiveplotlib.node import dataframe_to_node_list
28
28
 
29
29
 
@@ -163,7 +163,7 @@ def example_hive_plot(
163
163
  :param num_edges: number of edges to generate.
164
164
  :param seed: random seed to use when generating nodes and edges.
165
165
  :param hive_plot_n_axes_kwargs: additional keyword arguments for the underlying
166
- :py:func:`hiveplotlib.hive_plot.hive_plot_n_axes()` call.
166
+ :py:func:`hiveplotlib.hive_plot_n_axes()` call.
167
167
  :return: resulting ``HivePlot`` instance.
168
168
  """
169
169
  color_dict = {
@@ -266,3 +266,52 @@ def example_nodes_and_edges(
266
266
  edges = rng.choice(node_ids, size=num_edges * 2).reshape(-1, 2)
267
267
 
268
268
  return node_list, node_ids_per_axis, edges
269
+
270
+
271
+ def example_p2cp(
272
+ num_points: int = 50,
273
+ noise: float = 0.5,
274
+ random_seed: int = 0,
275
+ four_colors: Tuple[str, str, str, str] = (
276
+ "#de8f05",
277
+ "#029e73",
278
+ "#cc78bc",
279
+ "#0173b2",
280
+ ),
281
+ **p2cp_n_axes_kwargs,
282
+ ) -> P2CP:
283
+ """
284
+ Generate example P2CP of four gaussian blobs.
285
+
286
+ Points will be generated by calling :py:func:`hiveplotlib.datasets.four_gaussian_blobs_3d()` and turned into a P2CP
287
+ via :py:func:`hiveplotlib.p2cp_n_axes()`.
288
+
289
+ :param num_points: number of points in each Gaussian blob.
290
+ :param noise: noisiness of Gaussian blobs.
291
+ :param random_seed: random seed to generate consistent data between calls.
292
+ :param four_colors: four colors to use for four Gaussian blobs.
293
+ :param p2cp_n_axes_kwargs: additional keyword arguments for the underlying
294
+ :py:func:`hiveplotlib.p2cp_n_axes()` call.
295
+ :return: resulting ``P2CP`` instance.
296
+ """
297
+ # color palette for the blobs
298
+ df = four_gaussian_blobs_3d(
299
+ num_points=num_points,
300
+ noise=noise,
301
+ random_seed=random_seed,
302
+ )
303
+
304
+ # the first (0) blob needs to be plotted last, so let's give it the last label for pandas to sort to plot last
305
+ df.loc[df["Label"] == 0, "Label"] = 4
306
+
307
+ # align the colors with the figure from the paper
308
+ indices_dict = [{"color": color} for color in four_colors]
309
+
310
+ return p2cp_n_axes(
311
+ data=df,
312
+ split_on="Label",
313
+ vmins=[-1] * 3,
314
+ vmaxes=[6] * 3,
315
+ indices_list_kwargs=indices_dict,
316
+ **p2cp_n_axes_kwargs,
317
+ )
@@ -0,0 +1,165 @@
1
+ # base.py
2
+
3
+ """
4
+ Base (viz back-end-agnostic) functionality for visualizations in ``hiveplotlib``.
5
+ """
6
+
7
+ import warnings
8
+ from typing import Hashable, List, Literal, Tuple
9
+
10
+ from hiveplotlib import Axis, HivePlot
11
+
12
+
13
+ def get_axis_label_alignment(
14
+ axis: Axis,
15
+ backend: Literal["matplotlib", "bokeh", "holoviews", "plotly"],
16
+ horizontal_angle_span: float = 60,
17
+ vertical_angle_span: float = 60,
18
+ ) -> Tuple[Literal["bottom", "middle", "top"], Literal["left", "center", "right"]]:
19
+ """
20
+ Generate appropriate horizontal and vertical alignment for text at the radial end point of an ``Axis`` instance.
21
+
22
+ ``horizontal_angle_span`` and ``vertical_angle_span`` dictate the text alignment partition, measured in degrees. See
23
+ the below parameter descriptions for how each value is used to partition the angle space.
24
+
25
+ :param axis: ``Axis`` for which to generate the appropriate text alignment.
26
+ :param backend: which plotting back end to use. (Different back ends have different string names for their
27
+ alignment options.)
28
+ :param horizontal_angle_span: ``[-horizontal_angle_span, horizontal_angle_span]`` will be ``"left"`` aligned.
29
+ ``[180 - horizontal_angle_span, 180 + horizontal_angle_span]`` will be ``right`` aligned, and all other angles
30
+ will be ``"center"`` aligned.
31
+ :param vertical_angle_span: ``[90 - vertical_angle_span, 90 + vertical_angle_span]`` will be ``"bottom"`` aligned.
32
+ ``[270 - vertical_angle_span, 270 + vertical_angle_span]`` will be ``top`` aligned, and all other angles
33
+ will be ``"middle"`` aligned.
34
+ :return: vertical alignment string and horizontal alignment string appropriate for the edge of the provided
35
+ ``Axis`` instance.
36
+ """
37
+ horizontal_alignment_dict = {"left": "left", "center": "center", "right": "right"}
38
+ vertical_alignment_dict = {"bottom": "bottom", "middle": "middle", "top": "top"}
39
+
40
+ # matplotlib and holoviews have different naming convention than default
41
+ if backend in ["matplotlib", "holoviews"]:
42
+ vertical_alignment_dict["middle"] = "center"
43
+
44
+ # range in each direction from 0, 180 to specify horizontal alignment
45
+ if (
46
+ axis.angle >= 360 - horizontal_angle_span
47
+ or axis.angle <= 0 + horizontal_angle_span
48
+ ):
49
+ horizontalalignment = horizontal_alignment_dict["left"]
50
+ elif 180 + horizontal_angle_span >= axis.angle >= 180 - horizontal_angle_span:
51
+ horizontalalignment = horizontal_alignment_dict["right"]
52
+ else:
53
+ horizontalalignment = horizontal_alignment_dict["center"]
54
+
55
+ # range in each direction from 90, 270 to specify vertical alignment
56
+ if 90 + vertical_angle_span >= axis.angle >= 90 - vertical_angle_span:
57
+ verticalalignment = vertical_alignment_dict["bottom"]
58
+ elif 270 - vertical_angle_span <= axis.angle <= 270 + vertical_angle_span:
59
+ verticalalignment = vertical_alignment_dict["top"]
60
+ else:
61
+ verticalalignment = vertical_alignment_dict["middle"]
62
+
63
+ return verticalalignment, horizontalalignment
64
+
65
+
66
+ def edge_viz_preparation(
67
+ hive_plot: HivePlot,
68
+ name: Literal["Hive Plot", "P2CP"],
69
+ from_axis: Hashable,
70
+ to_axis: Hashable,
71
+ tag: Hashable,
72
+ already_warned_p2cp_tags: List[Hashable],
73
+ edge_kwargs: dict,
74
+ line_width_name: str,
75
+ line_alpha_name: str,
76
+ line_color_name: str,
77
+ default_line_width: float = 1.5,
78
+ default_line_alpha: float = 0.5,
79
+ default_line_color: str = "black",
80
+ include_line_alpha: bool = True,
81
+ include_line_width: bool = True,
82
+ ) -> Tuple[dict, List[Hashable]]:
83
+ """
84
+ Warning checks and keyword argument tracking specifically for ``edge_viz()`` for a subset of edges to plot.
85
+
86
+ This code is abstracted to ``hiveplotlib.viz.base`` to avoid redundancy for the ``edge_viz()`` calls with the
87
+ various back ends, but this function not intended for use outside of within ``edge_viz()``.
88
+
89
+ :param hive_plot: underlying hive plot to plot. Should never provide a ``P2CP`` instance here.
90
+ :param name: "Hive Plot" or "P2CP" being plotted (this affects which warning checks to perform).
91
+ :param from_axis: the "from" axis of edges currently being prepared for viz.
92
+ :param to_axis: the "to" axis of edges currently being prepared for viz.
93
+ :param tag: which tag of edges we are plotting.
94
+ :param already_warned_p2cp_tags: which tags we've already warned about (this avoids repeated warnings when plotting
95
+ ill-specified P2CPs).
96
+ :param edge_kwargs: user-provided edge kwargs to an ``edge_viz()`` call.
97
+ :param line_width_name: name of line width for viz back end.
98
+ :param line_alpha_name: name of line alpha for viz back end.
99
+ :param line_color_name: name of line color for viz back end.
100
+ :param default_line_width: default line width value.
101
+ :param default_line_alpha: default line alpha value.
102
+ :param default_line_color: default line color value.
103
+ :param include_line_alpha: whether to include the line alpha parameter or not. (We always want line alpha, but the
104
+ ``plotly`` back end requires including line alpha via the RGBA value, as standalone line alpha is not supported
105
+ for lines in ``plotly``.)
106
+ :param include_line_width: whether to include the line width parameter or not. (All viz back ends have a line width,
107
+ but the historical ``matplotlib`` implementation did not set a default width, which we will preserve going
108
+ forward.)
109
+ :return: dictionary of the resulting kwargs for the given edges being plotted and a list of P2CP tags that have been
110
+ warned about (the provided ``tag`` will be added if the provided P2CP is ill-specified).
111
+ """
112
+ temp_edge_kwargs = edge_kwargs.copy()
113
+
114
+ # only run plotting of edges that exist
115
+ if "curves" in hive_plot.edges[from_axis][to_axis][tag]:
116
+ # create edge_kwargs key if needed
117
+ if "edge_kwargs" not in hive_plot.edges[from_axis][to_axis][tag]:
118
+ hive_plot.edges[from_axis][to_axis][tag]["edge_kwargs"] = {}
119
+
120
+ # don't use kwargs specified in this function call if already specified
121
+ for k in list(temp_edge_kwargs.keys()):
122
+ if k in hive_plot.edges[from_axis][to_axis][tag]["edge_kwargs"]:
123
+ if name == "Hive Plot":
124
+ warnings.warn(
125
+ f"Specified kwarg {k} but already set as kwarg for edge tag {tag} "
126
+ f"going from edges {from_axis} to {to_axis}. Preserving kwargs already set.\n"
127
+ "(These kwargs can be changed using the `add_edge_kwargs()` method "
128
+ "for your `HivePlot` instance)",
129
+ stacklevel=3,
130
+ )
131
+ # only warn once per tag over all axes
132
+ elif name == "P2CP" and tag not in already_warned_p2cp_tags:
133
+ warnings.warn(
134
+ f"Specified kwarg {k} but already set as kwarg for edge tag {tag}. "
135
+ f"Preserving kwargs already set.\n"
136
+ "(These kwargs can be changed using the `add_edge_kwargs()` method "
137
+ "for your `P2CP` instance)",
138
+ stacklevel=3,
139
+ )
140
+ already_warned_p2cp_tags.append(tag)
141
+ del temp_edge_kwargs[k]
142
+
143
+ # some default kwargs for the axes if not specified anywhere
144
+ if (
145
+ line_color_name
146
+ not in hive_plot.edges[from_axis][to_axis][tag]["edge_kwargs"]
147
+ and line_color_name not in temp_edge_kwargs
148
+ ):
149
+ temp_edge_kwargs[line_color_name] = default_line_color
150
+ if (
151
+ line_alpha_name
152
+ not in hive_plot.edges[from_axis][to_axis][tag]["edge_kwargs"]
153
+ and line_alpha_name not in temp_edge_kwargs
154
+ and include_line_alpha
155
+ ):
156
+ temp_edge_kwargs[line_alpha_name] = default_line_alpha
157
+ if (
158
+ line_width_name
159
+ not in hive_plot.edges[from_axis][to_axis][tag]["edge_kwargs"]
160
+ and line_width_name not in temp_edge_kwargs
161
+ and include_line_width
162
+ ):
163
+ temp_edge_kwargs[line_width_name] = default_line_width
164
+
165
+ return temp_edge_kwargs, already_warned_p2cp_tags
@@ -12,14 +12,13 @@ except ImportError: # pragma: no cover
12
12
  "bokeh not installed, but can be installed by running `pip install hiveplotlib[bokeh]`"
13
13
  )
14
14
 
15
- import warnings
16
15
  from typing import Hashable, List, Optional, Union
17
16
 
18
17
  import numpy as np
19
18
 
20
19
  from hiveplotlib import P2CP, HivePlot
21
20
  from hiveplotlib.utils import polar2cartesian
22
- from hiveplotlib.viz.base import get_axis_label_alignment
21
+ from hiveplotlib.viz.base import edge_viz_preparation, get_axis_label_alignment
23
22
  from hiveplotlib.viz.input_checks import input_check
24
23
 
25
24
 
@@ -384,54 +383,21 @@ def edge_viz(
384
383
  )
385
384
 
386
385
  for tag in tags_to_plot:
387
- temp_edge_kwargs = edge_kwargs.copy()
386
+ temp_edge_kwargs, already_warned_p2cp_tags = edge_viz_preparation(
387
+ hive_plot=hive_plot,
388
+ name=name,
389
+ from_axis=a0,
390
+ to_axis=a1,
391
+ tag=tag,
392
+ already_warned_p2cp_tags=already_warned_p2cp_tags,
393
+ edge_kwargs=edge_kwargs,
394
+ line_width_name="line_width",
395
+ line_alpha_name="alpha",
396
+ line_color_name="color",
397
+ )
388
398
 
389
399
  # only run plotting of edges that exist
390
400
  if "curves" in hive_plot.edges[a0][a1][tag]:
391
- # create edge_kwargs key if needed
392
- if "edge_kwargs" not in hive_plot.edges[a0][a1][tag]:
393
- hive_plot.edges[a0][a1][tag]["edge_kwargs"] = {}
394
-
395
- # don't use kwargs specified in this function call if already specified
396
- for k in list(temp_edge_kwargs.keys()):
397
- if k in hive_plot.edges[a0][a1][tag]["edge_kwargs"]:
398
- if name == "Hive Plot":
399
- warnings.warn(
400
- f"Specified kwarg {k} but already set as kwarg for edge tag {tag} "
401
- f"going from edges {a0} to {a1}. Preserving kwargs already set.\n"
402
- "(These kwargs can be changed using the `add_edge_kwargs()` method "
403
- "for your `HivePlot` instance)",
404
- stacklevel=2,
405
- )
406
- # only warn once per tag over all axes
407
- elif name == "P2CP" and tag not in already_warned_p2cp_tags:
408
- warnings.warn(
409
- f"Specified kwarg {k} but already set as kwarg for edge tag {tag}. "
410
- f"Preserving kwargs already set.\n"
411
- "(These kwargs can be changed using the `add_edge_kwargs()` method "
412
- "for your `P2CP` instance)",
413
- stacklevel=2,
414
- )
415
- already_warned_p2cp_tags.append(tag)
416
- del temp_edge_kwargs[k]
417
-
418
- # some default kwargs for the axes if not specified anywhere
419
- if (
420
- "color" not in hive_plot.edges[a0][a1][tag]["edge_kwargs"]
421
- and "color" not in temp_edge_kwargs
422
- ):
423
- temp_edge_kwargs["color"] = "black"
424
- if (
425
- "alpha" not in hive_plot.edges[a0][a1][tag]["edge_kwargs"]
426
- and "alpha" not in temp_edge_kwargs
427
- ):
428
- temp_edge_kwargs["alpha"] = 0.5
429
- if (
430
- "line_width" not in hive_plot.edges[a0][a1][tag]["edge_kwargs"]
431
- and "line_width" not in temp_edge_kwargs
432
- ):
433
- temp_edge_kwargs["line_width"] = 1.5
434
-
435
401
  # grab the requested array of discretized curves
436
402
  edge_arr = hive_plot.edges[a0][a1][tag]["curves"]
437
403
  # if there's no actual edges there, don't plot
@@ -545,7 +511,7 @@ def hive_plot_viz(
545
511
  **axes_kwargs,
546
512
  )
547
513
 
548
- # do the centering / redim-ing if requested only before the last call, otherwise it will be overridden
514
+ # do the centering / redim-ing if requested only on the last call, otherwise it will be overridden
549
515
  node_viz(
550
516
  instance=hive_plot,
551
517
  fig=fig,
@@ -644,7 +610,7 @@ def p2cp_viz(
644
610
  **axes_kwargs,
645
611
  )
646
612
 
647
- # do the centering / redim-ing if requested only before the last call, otherwise it will be overridden
613
+ # do the centering / redim-ing if requested only on the last call, otherwise it will be overridden
648
614
  node_viz(
649
615
  instance=p2cp,
650
616
  fig=fig,