paulbrodersen / netgraph

Publication-quality network visualisations in python
GNU General Public License v3.0
667 stars 40 forks source link

How to modify node_label_fontdict? #36

Closed fishbacp closed 2 years ago

fishbacp commented 2 years ago

I apologize for posting this here, as it is not a bug or issue but instead a question regarding the adjustment of node label font sizes, one that I doubt would yield a response on StackOverflow.

At https://netgraph.readthedocs.io/en/latest/graph_classes.html

it states that node_label_fontdict consists of keyword arguments passed to matplotlib.text.Text. I'm looking at matplotlib.text.Text right now and see the familiar keyword argument fontsize. It's not clear what an example dictionary, node_label_fontdict would look like if I merely wanted to change my label font size.

BTW, this package is really nice. I plan to use it for community detection in the context of EEG signal analysis.

paulbrodersen commented 2 years ago

I apologize for posting this here, as it is not a bug or issue but instead a question regarding the adjustment of node label font sizes, one that I doubt would yield a response on StackOverflow.

That's totally fine. The fact that even after reading the documentation you are unsure what to do means that the documentation needs more work.

Basically, node_label_fontdict is dictionary with key-value pairs that are passed through to matplotlib.text.Text.

The following command sets the fontsize to 20 pts:

Graph(nx.complete_graph(7), node_labels=True, node_label_fontdict=dict(size=20))

There are a few more examples here.

paulbrodersen commented 2 years ago

Also, thanks to your post I just learnt that fontsize is now a valid keyword for matplotlib Text objects. It used to be just size, now both are supported in matplotlib. However, looking at my code, I can see at least one set of circumstances in which a font size specification via fontsize would not be correctly handled. So apologies if you tried using that keyword instead of size and you got an error. That is a proper bug.

fishbacp commented 2 years ago

Thanks so much. This is great!