summaryrefslogtreecommitdiff
path: root/examples/drawing/plot_custom_node_icons.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/drawing/plot_custom_node_icons.py')
-rw-r--r--examples/drawing/plot_custom_node_icons.py7
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()