risk-network 0.0.8b8__tar.gz → 0.0.8b9__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.
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/PKG-INFO +1 -1
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/__init__.py +1 -1
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/network/plot/canvas.py +8 -5
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/network/plot/plotter.py +16 -2
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/risk.py +3 -5
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk_network.egg-info/PKG-INFO +1 -1
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/LICENSE +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/MANIFEST.in +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/README.md +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/pyproject.toml +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/annotations/__init__.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/annotations/annotations.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/annotations/io.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/constants.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/log/__init__.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/log/config.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/log/params.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/neighborhoods/__init__.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/neighborhoods/community.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/neighborhoods/domains.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/neighborhoods/neighborhoods.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/network/__init__.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/network/geometry.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/network/graph.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/network/io.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/network/plot/__init__.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/network/plot/contour.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/network/plot/labels.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/network/plot/network.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/network/plot/utils.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/stats/__init__.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/stats/hypergeom.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/stats/permutation/__init__.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/stats/permutation/permutation.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/stats/permutation/test_functions.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/stats/poisson.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk/stats/stats.py +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk_network.egg-info/SOURCES.txt +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk_network.egg-info/dependency_links.txt +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk_network.egg-info/requires.txt +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/risk_network.egg-info/top_level.txt +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/setup.cfg +0 -0
- {risk_network-0.0.8b8 → risk_network-0.0.8b9}/setup.py +0 -0
@@ -44,8 +44,8 @@ class Canvas:
|
|
44
44
|
Args:
|
45
45
|
title (str, optional): Title of the plot. Defaults to None.
|
46
46
|
subtitle (str, optional): Subtitle of the plot. Defaults to None.
|
47
|
-
title_fontsize (int, optional): Font size for the title. Defaults to
|
48
|
-
subtitle_fontsize (int, optional): Font size for the subtitle. Defaults to
|
47
|
+
title_fontsize (int, optional): Font size for the title. Defaults to 20.
|
48
|
+
subtitle_fontsize (int, optional): Font size for the subtitle. Defaults to 14.
|
49
49
|
font (str, optional): Font family used for both title and subtitle. Defaults to "Arial".
|
50
50
|
title_color (str, optional): Color of the title text. Defaults to "black".
|
51
51
|
subtitle_color (str, optional): Color of the subtitle text. Defaults to "gray".
|
@@ -90,11 +90,14 @@ class Canvas:
|
|
90
90
|
|
91
91
|
# Plot subtitle if provided
|
92
92
|
if subtitle:
|
93
|
-
# Calculate the subtitle's y position based on title
|
94
|
-
|
93
|
+
# Calculate the subtitle's y position based on the midpoint of the title and subtitle_offset
|
94
|
+
# Calculate the approximate height of the title in relative axis units
|
95
|
+
title_height = title_fontsize / fig.bbox.height
|
96
|
+
# Position the subtitle relative to the title's center (title_y - half the title height)
|
97
|
+
subtitle_y_position = title_y - (title_height / 2) - subtitle_offset
|
95
98
|
self.ax.figure.text(
|
96
99
|
0.5, # Ensure horizontal centering for subtitle
|
97
|
-
subtitle_y_position,
|
100
|
+
subtitle_y_position, # Position subtitle based on the center of the title
|
98
101
|
subtitle,
|
99
102
|
ha="center",
|
100
103
|
va="top",
|
@@ -8,6 +8,7 @@ from typing import List, Tuple, Union
|
|
8
8
|
import matplotlib.pyplot as plt
|
9
9
|
import numpy as np
|
10
10
|
|
11
|
+
from risk.log import params
|
11
12
|
from risk.network.graph import NetworkGraph
|
12
13
|
from risk.network.plot.canvas import Canvas
|
13
14
|
from risk.network.plot.contour import Contour
|
@@ -30,6 +31,7 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
|
|
30
31
|
figsize: Tuple = (10, 10),
|
31
32
|
background_color: Union[str, List, Tuple, np.ndarray] = "white",
|
32
33
|
background_alpha: Union[float, None] = 1.0,
|
34
|
+
pad: float = 0.3,
|
33
35
|
) -> None:
|
34
36
|
"""Initialize the NetworkPlotter with a NetworkGraph object and plotting parameters.
|
35
37
|
|
@@ -39,6 +41,7 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
|
|
39
41
|
background_color (str, list, tuple, np.ndarray, optional): Background color of the plot. Defaults to "white".
|
40
42
|
background_alpha (float, None, optional): Transparency level of the background color. If provided, it overrides
|
41
43
|
any existing alpha values found in background_color. Defaults to 1.0.
|
44
|
+
pad (float, optional): Padding value to adjust the axis limits. Defaults to 0.3.
|
42
45
|
"""
|
43
46
|
self.graph = graph
|
44
47
|
# Initialize the plot with the specified parameters
|
@@ -47,6 +50,7 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
|
|
47
50
|
figsize=figsize,
|
48
51
|
background_color=background_color,
|
49
52
|
background_alpha=background_alpha,
|
53
|
+
pad=pad,
|
50
54
|
)
|
51
55
|
super().__init__(graph=graph, ax=self.ax)
|
52
56
|
|
@@ -56,6 +60,7 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
|
|
56
60
|
figsize: Tuple,
|
57
61
|
background_color: Union[str, List, Tuple, np.ndarray],
|
58
62
|
background_alpha: Union[float, None],
|
63
|
+
pad: float,
|
59
64
|
) -> plt.Axes:
|
60
65
|
"""Set up the plot with figure size and background color.
|
61
66
|
|
@@ -65,10 +70,19 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
|
|
65
70
|
background_color (str): Background color of the plot.
|
66
71
|
background_alpha (float, None, optional): Transparency level of the background color. If provided, it overrides any
|
67
72
|
existing alpha values found in background_color.
|
73
|
+
pad (float, optional): Padding value to adjust the axis limits.
|
68
74
|
|
69
75
|
Returns:
|
70
76
|
plt.Axes: The axis object for the plot.
|
71
77
|
"""
|
78
|
+
# Log the plotter settings
|
79
|
+
params.log_plotter(
|
80
|
+
figsize=figsize,
|
81
|
+
background_color=background_color,
|
82
|
+
background_alpha=background_alpha,
|
83
|
+
pad=pad,
|
84
|
+
)
|
85
|
+
|
72
86
|
# Extract node coordinates from the network graph
|
73
87
|
node_coordinates = graph.node_coordinates
|
74
88
|
# Calculate the center and radius of the bounding box around the network
|
@@ -78,8 +92,8 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
|
|
78
92
|
fig, ax = plt.subplots(figsize=figsize)
|
79
93
|
fig.tight_layout() # Adjust subplot parameters to give specified padding
|
80
94
|
# Set axis limits based on the calculated bounding box and radius
|
81
|
-
ax.set_xlim([center[0] - radius -
|
82
|
-
ax.set_ylim([center[1] - radius -
|
95
|
+
ax.set_xlim([center[0] - radius - pad, center[0] + radius + pad])
|
96
|
+
ax.set_ylim([center[1] - radius - pad, center[1] + radius + pad])
|
83
97
|
ax.set_aspect("equal") # Ensure the aspect ratio is equal
|
84
98
|
|
85
99
|
# Set the background color of the plot
|
@@ -356,6 +356,7 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
356
356
|
figsize: Tuple = (10, 10),
|
357
357
|
background_color: str = "white",
|
358
358
|
background_alpha: Union[float, None] = 1.0,
|
359
|
+
pad: float = 0.3,
|
359
360
|
) -> NetworkPlotter:
|
360
361
|
"""Get a NetworkPlotter object for plotting.
|
361
362
|
|
@@ -365,16 +366,12 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
365
366
|
background_color (str, optional): Background color of the plot. Defaults to "white".
|
366
367
|
background_alpha (float, None, optional): Transparency level of the background color. If provided, it overrides
|
367
368
|
any existing alpha values found in background_color. Defaults to 1.0.
|
369
|
+
pad (float, optional): Padding value to adjust the axis limits. Defaults to 0.3.
|
368
370
|
|
369
371
|
Returns:
|
370
372
|
NetworkPlotter: A NetworkPlotter object configured with the given parameters.
|
371
373
|
"""
|
372
374
|
log_header("Loading plotter")
|
373
|
-
# Log the plotter settings
|
374
|
-
params.log_plotter(
|
375
|
-
figsize=figsize,
|
376
|
-
background_color=background_color,
|
377
|
-
)
|
378
375
|
|
379
376
|
# Initialize and return a NetworkPlotter object
|
380
377
|
return NetworkPlotter(
|
@@ -382,6 +379,7 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
382
379
|
figsize=figsize,
|
383
380
|
background_color=background_color,
|
384
381
|
background_alpha=background_alpha,
|
382
|
+
pad=pad,
|
385
383
|
)
|
386
384
|
|
387
385
|
def _load_neighborhoods(
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|