diff options
author | Mridul Seth <seth.mridul@gmail.com> | 2021-05-11 20:56:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-11 14:56:44 -0400 |
commit | f07f1995107aeaaf7ade82e73e83dcf80b94bdfd (patch) | |
tree | 1b9022f66655e6ae5c458d2adce9b7fcfe4efe3d | |
parent | ba73110a26e574f896fac75dba20f73fb5a9c421 (diff) | |
download | networkx-f07f1995107aeaaf7ade82e73e83dcf80b94bdfd.tar.gz |
imread(url) is deprecated, use pillow + urllib to load image from URL (#4790)
-rw-r--r-- | examples/drawing/plot_custom_node_icons.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/drawing/plot_custom_node_icons.py b/examples/drawing/plot_custom_node_icons.py index aa880802..d221d955 100644 --- a/examples/drawing/plot_custom_node_icons.py +++ b/examples/drawing/plot_custom_node_icons.py @@ -7,8 +7,9 @@ Example of using custom icons to represent nodes with matplotlib. """ import matplotlib.pyplot as plt -import matplotlib.image as mpimg import networkx as nx +import PIL +import urllib # Image URLs for graph nodes icon_urls = { @@ -18,7 +19,9 @@ icon_urls = { } # Load images from web -images = {k: mpimg.imread(url) for k, url in icon_urls.items()} +images = { + k: PIL.Image.open(urllib.request.urlopen(url)) for k, url in icon_urls.items() +} # Generate the computer network graph G = nx.Graph() |