I have this code:
labels_params = {"labels":{n: "" if n[0] == "." else n for n in G.nodes () },
"font_family":"sans-serif",
"alpha":.5,
"font_size":16 }
draw_networkx_labels (G, pos, **labels_params)
My problem is that I wish to be able to display in my output graph more than 2 fonts .
I wish to know how can I detect all possible entries for "font_family".
I browsed the code of FontManager from Networkx, and I see only "sans-serif".
I am working in X11 under Ubuntu.
Poking around a bit in the
draw_networkx_labels
source, it does indeed come down to a call toax.text
(where ax is a matplotlib axis). So that means you should have as much configurability as you get with any normal MPL text (docs).Font names vs font families
As far as I can tell, a font name is an instance of a font family; though because the generic families (eg 'serif') are often given as settings to font family variables. http://www.w3schools.com/css/css_font.asp
This has confused me for a while, so please correct me if I'm wrong here.
Finding the full list of fonts
So if you use the technique from here:
you get all the (specific) options. Don't know where you find a fuller list than the font demo for generics.
this post shows a method for searching by name:
Using more than one font for labels in your graph
From the
avail_font_names
list above, I picked out three for this example; you might have to substitute some of them depending on what you have installed.Resolving the 'Falling back to ...' warnings
Note: if you get errors when of the form "UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to ...", when trying to use fonts even if they do exist, this nabble dialog suggests clearing the font cache: (yup, this will irretrievably remove a file but it is auto-generated.)