I want to plot a graph using networkx. But module 'matplotlib.pyplot' has no attribute 'ishold' error is coming. I have tried using the earlier versions of matplotlib but it didn't work. Yesterday, the same code was running but now it is showing this error. Please help. Im stuck.
I have tried using the earlier versions of matplotlib but it didn't work. Yesterday, the same code was running but now it is showing this error. Please help. Im stuck.
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
G = nx.Graph()
G.add_edges_from(
[('A', 'B'), ('A', 'C'), ('D', 'B'), ('E', 'C'), ('E', 'F'),
('B', 'H'), ('B', 'G'), ('B', 'F'), ('C', 'G')])
val_map = {'A': 1.0,
'D': 0.5714285714285714,
'H': 0.0}
values = [val_map.get(node, 0.25) for node in G.nodes()]
%matplotlib inline
nx.draw_networkx(G, cmap = plt.get_cmap('jet'), node_color = values)
nx.draw(G)
plt.show()
AttributeError Traceback (most recent call last)
<ipython-input-13-127734f4f34b> in <module>()
14 values = [val_map.get(node, 0.25) for node in G.nodes()]
15 get_ipython().magic('matplotlib inline')
---> 16 nx.draw_networkx(G, cmap = plt.get_cmap('jet'), node_color = values)
17
18 nx.draw(G)
1 frames
/usr/local/lib/python3.6/dist-packages/networkx/drawing/nx_pylab.py in draw_networkx_edges(G, pos, edgelist, width, edge_color, style, alpha, edge_cmap, edge_vmin, edge_vmax, ax, arrows, label, **kwds)
520 lw = width
521
--> 522 if not cb.is_string_like(edge_color) \
523 and cb.iterable(edge_color) \
524 and len(edge_color) == len(edge_pos):
AttributeError: module 'matplotlib.cbook' has no attribute 'is_string_like'