Repository: networkx/networkx

Issue:
compatibility with matplotlib-3.0.0 ?
running this code:
````
# Networks graph Example : https://github.com/ipython/ipywidgets/blob/master/examples/Exploring%20Graphs.ipynb
%matplotlib inline
from ipywidgets import interact
import matplotlib.pyplot as plt
import networkx as nx
# wrap a few graph generation functions so they have the same signature

def random_lobster(n, m, k, p):
    return nx.random_lobster(n, p, p / m)

def powerlaw_cluster(n, m, k, p):
    return nx.powerlaw_cluster_graph(n, m, p)

def erdos_renyi(n, m, k, p):
    return nx.erdos_renyi_graph(n, p)

def newman_watts_strogatz(n, m, k, p):
    return nx.newman_watts_strogatz_graph(n, k, p)

@interact(n=(2,30), m=(1,10), k=(1,10), p=(0.0, 1.0, 0.001),
        generator={'lobster': random_lobster,
                   'power law': powerlaw_cluster,
                   'Newman-Watts-Strogatz': newman_watts_strogatz,
                   u'Erdős-Rényi': erdos_renyi,
                   })
def plot_random_graph(n, m, k, p, generator):
    g = generator(n, m, k, p)
    nx.draw(g)
    plt.title(generator.__name__)
    plt.show()
````

I get this warning:
````
...python-3.7.1rc1.amd64\lib\site-packages\networkx\drawing\nx_pylab.py:611: MatplotlibDeprecationWarning: isinstance(..., numbers.Number)
  if cb.is_numlike(alpha):
````

coming from this https://github.com/matplotlib/matplotlib/commit/1f923d40d67d95a0d0aa3cdaea329ce9c4296d90

so you may have to replace:
````
if cb.is_numlike(alpha):
````
per something like ?
````
if cb.isinstance(alpha, Number)
````


Discussion:
It looks like their suggested fix is to use ```isinstance(alpha, numbers.Number)```.
We don't need ```cb.``` in front of ```isinstance```. We do need the ```numbers``` package.

Thanks for this...  I'll put the label for "Needs PR"

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
@@ -26,6 +26,7 @@
 from networkx.drawing.layout import shell_layout, \
     circular_layout, kamada_kawai_layout, spectral_layout, \
     spring_layout, random_layout
+from numbers import Number
 
 __all__ = ['draw',
            'draw_networkx',
@@ -608,7 +609,7 @@ def draw_networkx_edges(G, pos,
         # r7184 and r7189 (June 6 2009). We should then not set the alpha
         # value globally, since the user can instead provide per-edge alphas
         # now.  Only set it globally if provided as a scalar.
-        if cb.is_numlike(alpha):
+        if isinstance(alpha, Number):
             edge_collection.set_alpha(alpha)
 
         if edge_colors is None:
@@ -1094,7 +1095,6 @@ def apply_alpha(colors, alpha, elem_list, cmap=None, vmin=None, vmax=None):
         Array containing RGBA format values for each of the node colours.
 
     """
-    import numbers
     from itertools import islice, cycle
 
     try:
@@ -1106,7 +1106,7 @@ def apply_alpha(colors, alpha, elem_list, cmap=None, vmin=None, vmax=None):
 
     # If we have been provided with a list of numbers as long as elem_list,
     # apply the color mapping.
-    if len(colors) == len(elem_list) and isinstance(colors[0], numbers.Number):
+    if len(colors) == len(elem_list) and isinstance(colors[0], Number):
         mapper = cm.ScalarMappable(cmap=cmap)
         mapper.set_clim(vmin, vmax)
         rgba_colors = mapper.to_rgba(colors)


Test patch: