Repository: networkx/networkx

Issue:
unable to add colorbar to a MultiDiGraph for networkx >= 2.1
In networkx 2.0, `nx.draw_networkx_edges()` returned a `LineCollection`, which you could then pass to matplotlib's `colorbar()` to get a colorbar showing the scale of the colors for the edges.

In networkx 2.1, it now returns a list of `FancyArrowPatch`s, and `colorbar()` complains that these are not mappable.  Is there a new way to add a colorbar to a directed graph for networkx >= 2.1?  I couldn't find anything in the docs.


Discussion:
Too bad this feature was lost (or not as easy). The FancyArrowPatchs give us many nice features.

It looks like the colorbar features of Matplotlib include a ColorbarPatch. 
Can you try the answers in [this stackoverflow answer](https://stackoverflow.com/questions/18658047/adding-a-matplotlib-colorbar-from-a-patchcollection) to see if something similar can work here?

thanks, I'll give that a try
that worked great.  See the issue I linked above for example output -- the new arrows are much nicer.  For the record, here's what I had to do:

 `draw_networkx_edges` returns a list of `FancyArrayPatch`s now

```
           pc = mpl.collections.PatchCollection(edges_lc, cmap=plt.cm.viridis)
           pc.set_array(weights)
           plt.colorbar(pc)
```

where `weights` is the array of weights I used for `edge_color` in the call to `draw_networkx_edges()`

I'll explore adding a simple example of this to your gallery via a PR later today.                                  

here's a simple example using one of the gallery examples from the networkx documentation:

https://networkx.github.io/documentation/stable/auto_examples/drawing/plot_directed.html#sphx-glr-auto-examples-drawing-plot-directed-py

```
from __future__ import division
import matplotlib as mpl
import matplotlib.pyplot as plt
import networkx as nx

G = nx.generators.directed.random_k_out_graph(10, 3, 0.5)
pos = nx.layout.spring_layout(G)

node_sizes = [3 + 10 * i for i in range(len(G))]
M = G.number_of_edges()
edge_colors = range(2, M + 2)
edge_alphas = [(5 + i) / (M + 4) for i in range(M)]

nodes = nx.draw_networkx_nodes(G, pos, node_size=node_sizes, node_color='blue')
edges = nx.draw_networkx_edges(G, pos, node_size=node_sizes, arrowstyle='->',
                               arrowsize=10, edge_color=edge_colors,
                               edge_cmap=plt.cm.Blues, width=2)
# set alpha value for each edge
for i in range(M):
    edges[i].set_alpha(edge_alphas[i])

pc = mpl.collections.PatchCollection(edges, cmap=plt.cm.Blues)
pc.set_array(edge_colors)
plt.colorbar(pc)

ax = plt.gca()
ax.set_axis_off()
plt.savefig("digraph_colorbar.png")
```

gives:

![digraph_colorbar](https://user-images.githubusercontent.com/7817509/37105507-596e1da8-21fd-11e8-90bd-e54d026c4895.png)



Resolving patch:
diff --git a/examples/drawing/plot_directed.py b/examples/drawing/plot_directed.py
--- a/examples/drawing/plot_directed.py
+++ b/examples/drawing/plot_directed.py
@@ -11,6 +11,7 @@
 # Author: Rodrigo Dorantes-Gilardi (rodgdor@gmail.com)
 
 from __future__ import division
+import matplotlib as mpl
 import matplotlib.pyplot as plt
 import networkx as nx
 
@@ -30,6 +31,10 @@
 for i in range(M):
     edges[i].set_alpha(edge_alphas[i])
 
+pc = mpl.collections.PatchCollection(edges, cmap=plt.cm.Blues)
+pc.set_array(edge_colors)
+plt.colorbar(pc)
+
 ax = plt.gca()
 ax.set_axis_off()
 plt.show()


Test patch: