Skip to content

Commit 832d387

Browse files
committed
Adjust dynamic sizing on circular graphs
1 parent 35b5aba commit 832d387

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

mathicsscript/format.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@ def spiral_equidistant_layout(G, *args, **kwargs):
285285
"tree": tree_layout,
286286
}
287287

288+
LAYOUT_DENSITY_EXPONENT = {
289+
"circular": 0.9,
290+
"spiral_equidistant": 0.7,
291+
"spiral": 0.6,
292+
}
288293

289294
def clamp(value, min=-math.inf, max=math.inf):
290295
if value <= min:
@@ -309,12 +314,9 @@ def harmonize_parameters(G, draw_options: dict):
309314
tree_layout(G)
310315
draw_options["node_size"] = node_size
311316
elif graph_layout in ["circular", "spiral", "spiral_equidistant"]:
312-
# FIXME spiral is more 2D filling
313-
# Instead of Sqrt use adjusted exponent like **0.6
314-
# and mayb for spiral **0.7
315-
node_size = draw_options["node_size"] = (2 * DEFAULT_NODE_SIZE) / math.sqrt(
316-
len(G) + 1
317-
)
317+
exponent = LAYOUT_DENSITY_EXPONENT[graph_layout]
318+
node_size = draw_options["node_size"] = (2 * DEFAULT_NODE_SIZE) / (len(G)+1) ** exponent
319+
# print("XX", node_size, exponent)
318320

319321
if draw_options.get("with_labels", False):
320322
draw_options["edgecolors"] = draw_options.get("edgecolors", "black")

0 commit comments

Comments
 (0)