Repository: networkx/networkx

Issue:
Edge plots no longer work the same 2.3 vs 2.4
We have used the nx.draw_networkx_nodes and nx.draw_networkx_edges functions together to plot node and edge color scales separately, for example, pressure at nodes and flow through pipes (edges). This is no longer working in NetworkX 2.4. The graphics below show identical code, run on 2.3 and 2.4. In NetworkX 2.4, the edges are being colored according to the node colormap, but no values are being assigned to the edge colorbar. 

The code below does not contain full details, but is meant to show which options we are passing in.

`nodes = nx.draw_networkx_nodes(G, pos, with_labels=False, nodelist=nodelist, node_color=nodecolor, node_size=node_size, alpha=node_alpha, cmap=node_cmap, vmin=node_range[0], vmax = node_range[1], linewidths=0, ax=ax)`
`edges = nx.draw_networkx_edges(G, pos, edgelist=linklist, edge_color=linkcolor, width=link_width, alpha=link_alpha, edge_cmap=link_cmap,  edge_vmin=link_range[0], edge_vmax=link_range[1], ax=ax)`
`plt.colorbar(nodes, shrink=0.5, pad=0, ax=ax)`
`plt.colorbar(edges, shrink=0.5, pad=0.05, ax=ax)`

![Net6-nx-2 3-plot](https://user-images.githubusercontent.com/5519689/67789701-06c2fd00-fa3a-11e9-8218-e9c8da3e3732.png)

![Figure_2_nx24](https://user-images.githubusercontent.com/5519689/67789707-09bded80-fa3a-11e9-9e6a-7a57336ac038.png)



Discussion:
Thanks for this -- wow...   its weird...  Do I understand correctly that the edges and edge colors are drawn the same in both versions, but the colorbar is different. And the colorbar is the only thing that is different that you have noticed...???

Does the same thing have with a small graph or say 2-4 edges?
So, yes on both counts. The only difference between the generation of the two graphs was running “conda update networkx” between running the script the first and second time. Conda only updated networkx, all other packages (matplotlib in particular to 3.1.1) had been updated prior to the first run.

We’ve run this on a network with 10 nodes and edges, and it did the same thing.

Within draw_networkx_edges, the LineCollection needs cmap and clim defined before it is returned. Something like this should work.

```
edge_collection.set_cmap(edge_cmap)
edge_collection.set_clim(edge_vmin, edge_vmax)
```
Thanks @kaklise !!

Can you (@dbhart )verify that by adding these two lines before the ```plt.colorbar``` lines does the trick?

    edge_collection.set_cmap(link_cmap)
    edge_collection.set_clim(link_range[0], link_range[1])
I'm running the same example as @dbhart , and this works as long as the min and max in link_range are not None.  This is handled inside draw_networkx_edges, where vmin and vmax can be defined based on the edge color.  The resulting figure is now matches 2.3.  
Excellent!   Thanks!
Are you up for creating a PR or should I do that? 
Not sure how to add a test of the colorbar being correct... :{
I can submit a PR (I'm not sure how to test colorbars either)

Resolving patch:
diff --git a/networkx/drawing/nx_pylab.py b/networkx/drawing/nx_pylab.py
--- a/networkx/drawing/nx_pylab.py
+++ b/networkx/drawing/nx_pylab.py
@@ -612,6 +612,9 @@ def draw_networkx_edges(G, pos,
                                          alpha=alpha
                                          )
 
+        edge_collection.set_cmap(edge_cmap)
+        edge_collection.set_clim(edge_vmin, edge_vmax)
+
         edge_collection.set_zorder(1)  # edges go behind nodes
         edge_collection.set_label(label)
         ax.add_collection(edge_collection)


Test patch: