- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to draw node colormap in NetworkX/Matplotlib?
To draw node colormap in matplotlib/netwokx, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Return the cycle graph $C_n$ of cyclically connected nodes.
- Position the nodes on a circle.
- Draw the graph G with Matplotlib.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt import networkx as nx plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True G = nx.cycle_graph(24) pos = nx.circular_layout(G) nx.draw(G, pos, node_color=range(24), node_size=800, cmap='copper') plt.show()
Output
- Related Articles
- How to show node name in Matplotlib graphs using networkx?
- How can one modify the outline color of a node in networkx using Matplotlib?
- How to set a default colormap in Matplotlib?
- How to make the Parula colormap in Matplotlib?
- How to set NetworkX edge labels offset in Matplotlib?
- How to extract a subset of a colormap as a new colormap in Matplotlib?
- How to increase colormap/linewidth quality in streamplot Matplotlib?
- How to make multipartite graphs using networkx and Matplotlib?
- How to display the matrix value and colormap in Matplotlib?
- Extract Matplotlib colormap in hex-format
- How to plot data into imshow() with custom colormap in Matplotlib?
- Add alpha to an existing Matplotlib colormap
- How to use an update function to animate a NetworkX graph in Matplotlib?
- How to shade points in a scatter based on colormap in Matplotlib?
- How to change the attributes of a networkx / matplotlib graph drawing?

Advertisements