Skip to content

Commit e54e314

Browse files
committed
Bugfix: disable automatic node label font size rescaling if the fontsize is specified using the fontsize keyword
Previously, only the `size` keyword resulted in the correct behaviour.
1 parent c883513 commit e54e314

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ help(EditableGraph)
105105

106106
## Recent changes
107107

108+
- 4.12.10 Fixed a bug with automatic node label rescaling if the node label fontsize was specified using the `fontsize` keyword argument (instead of just `size`).
109+
- 4.12.9 Fixed a bug that occurred when the distance argument to `_shorten_line_by` was equal or smaller than zero.
108110
- 4.12.8 Fixed a bug that occurred with recent numpy versions when using multi-partite or shell layouts with un-equal numbers of nodes in each layer (issue #65).
109111
- 4.12.7 Fixed a bug that occurred with recent matplotlib versions when using the rectangle selector in `InteractiveGraph`.
110112
- 4.12.6 Added support for graphs with nodes but no edges to `EditableGraph` (issue #62).

netgraph/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
>>> help(EditableGraph)
9999
"""
100100

101-
__version__ = "4.12.9"
101+
__version__ = "4.12.10"
102102
__author__ = "Paul Brodersen"
103103
__email__ = "[email protected]"
104104

netgraph/_main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,8 @@ def _initialize_node_label_fontdict(self, node_label_fontdict, node_labels, node
884884
# Labels are centered on node artists.
885885
# Set fontsize such that labels fit the diameter of the node artists.
886886
size = self._get_font_size(node_labels, node_label_fontdict) * 0.75 # conservative fudge factor
887-
node_label_fontdict.setdefault('size', size)
887+
if ('size' not in node_label_fontdict) and ('fontsize' not in node_label_fontdict):
888+
node_label_fontdict.setdefault('size', size)
888889

889890
return node_label_fontdict
890891

@@ -904,6 +905,8 @@ def _get_font_size(self, node_labels, node_label_fontdict):
904905

905906
if 'size' in node_label_fontdict:
906907
size = rescale_factor * node_label_fontdict['size']
908+
elif 'fontsize' in node_label_fontdict:
909+
size = rescale_factor * node_label_fontdict['fontsize']
907910
else:
908911
size = rescale_factor * plt.rcParams['font.size']
909912
return size

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def read_file(filename):
66
with open(os.path.join(os.path.dirname(__file__), filename)) as file:
77
return file.read()
88

9-
version = '4.12.9'
9+
version = '4.12.10'
1010

1111
setup(
1212
name='netgraph',

0 commit comments

Comments
 (0)