Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8909639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:28:55+00:00 2026-06-15T03:28:55+00:00

NetworkX includes functions for drawing a graph using matplotlib . This is an example

  • 0

NetworkX includes functions for drawing a graph using matplotlib. This is an example using the great IPython Notebook (started with ipython3 notebook --pylab inline):

enter image description here

Nice, for a start. But how can I influence attributes of the drawing, like coloring, line width and labelling? I have not worked with matplotlib before.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:28:56+00:00Added an answer on June 15, 2026 at 3:28 am

    IPython is a great tool for finding out what functions (and objects) can do. If you type

    [1]: import networkx as nx
    [2]: nx.draw?
    

    you see

    Definition: nx.draw(G, pos=None, ax=None, hold=None, **kwds)

    **kwds: optional keywords
       See networkx.draw_networkx() for a description of optional keywords.
    

    And if you therefore type

    [10]: nx.draw_networkx?
    

    you will see

    node_color: color string, or array of floats
    edge_color: color string, or array of floats
    width: float
       Line width of edges (default =1.0)
    labels: dictionary
       Node labels in a dictionary keyed by node of text labels (default=None)
    

    So, armed with this information, and a bit of experimentation, it is not hard to arrive at:

    import matplotlib.pyplot as plt
    import numpy as np
    import networkx as nx
    import string
    
    G = nx.generators.erdos_renyi_graph(18, 0.2)
    nx.draw(G,
            node_color = np.linspace(0,1,len(G.nodes())),
            edge_color = np.linspace(0,1,len(G.edges())),
            width = 3.0,
            labels = {n:l for n,l in zip(G.nodes(),string.ascii_uppercase)}
            )
    plt.show()
    

    which yields

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'am using this datetimepicker on my website. My html file includes .js and .css
I noticed SmashingMagazine released a Smashing Network feature, which includes other website's posts. This
I was wondering how can we can use the python module networkX to implement
Boost Network I am trying out this code in a small console app on
Am having problems with PHP's require_once, require, include_once and include functions not correctly resolving
I have an API in NETMF C# that I am writing that includes a
I've found a sample about using Gnome Keyrings, but I'm unable to compile it,
Background: I have a DLL I created that includes 2 c files. These c
I am creating a neural network using MATLAB (version specified in title). After reading
I'm trying to get the traffic generated by my application. It includes a video

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.