import networkx as nx
G = nx.path_graph(3)
pos = nx.spring_layout(G)
nx.draw(G, pos)
x, y = pos[1]
import matplotlib.pyplot as plt
plt.text(x, y + 0.1, s='some text', bbox=dict(facecolor='red', alpha=0.5),
    horizontalalignment='center')
Networkx in Python - draw node attributes as labels outside the node