I have tried to draw lexicographic graphs with python33 networkx and matplotlib running on Linux Fedora 19 KDE, 64 bits. When feeding English script as input data, the graph
For Arabic in matplotlib you need bidi.algorithm.get_display
and arabic_reshaper modules:
from bidi.algorithm import get_display
import matplotlib.pyplot as plt
import arabic_reshaper
import networkx as nx
# Arabic text preprocessing
reshaped_text = arabic_reshaper.reshape(u'لغةٌ عربيّة')
artext = get_display(reshaped_text)
# constructing the sample graph
G=nx.Graph()
G.add_edge('a', artext ,weight=0.6)
pos=nx.spring_layout(G)
nx.draw_networkx_nodes(G,pos,node_size=700)
nx.draw_networkx_edges(G,pos,edgelist=G.edges(data=True),width=6)
# Drawing Arabic text
# Just Make sure your version of the font 'Times New Roman' has Arabic in it.
# You can use any Arabic font here.
nx.draw_networkx_labels(G,pos,font_size=20,font_family='Times New Roman')
# showing the graph
plt.axis('off')
plt.show()