

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Creating curved edges with NetworkX in Python3 (Matplotlib)
To create curved edges with NetworkX in Python3, we can use connectionstyle="arc3, rad=0.4".
Steps
- Set the figure size and adjust the padding between and around the subplots.
- Initialize a graph with edges, name, and graph attributes.
- Add nodes to the created graph.
- Add edges from one node to another.
- Draw the graph G with Matplotlib, with connectionstyle="arc3, rad=0.4".
- To display the figure, use show() method.
Example
import matplotlib.pylab as plt import networkx as nx plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True G = nx.DiGraph() pos = nx.spring_layout(G) G.add_nodes_from([1, 2, 3, 4]) G.add_edges_from([(1, 2), (2, 4), (2, 3), (4, 1)]) nx.draw(G, with_labels=True, connectionstyle="arc3,rad=0.4") plt.show()
Output
- Related Questions & Answers
- Colouring the edges by weight in networkx (Matplotlib)
- Drawing a network graph with networkX and Matplotlib
- Matplotlib – Drawing lattices and graphs with Networkx
- Creating a Heatmap in matplotlib with pcolor
- How to draw node colormap in NetworkX/Matplotlib?
- How to implement Dictionary with Python3
- How to set NetworkX edge labels offset in Matplotlib?
- How to put a title for a curved line in Python Matplotlib?
- Text Analysis in Python3
- How to make multipartite graphs using networkx and Matplotlib?
- How to show node name in Matplotlib graphs using networkx?
- Creating 3D animation using matplotlib
- Creating a graph with date and time in axis labels with Matplotlib
- How to change the attributes of a networkx / matplotlib graph drawing?
- Shortest path with exactly k Edges
Advertisements