Python+NetworkX画图的nx.draw_networkx(函数详解)
Python+NetworkX画图的nx.draw_networkx函数详解
- Python+NetworkX画图的nx.draw_networkx(函数详解)
Python+NetworkX画图的nx.draw_networkx(函数详解)
def draw_networkx(G, pos=None, arrows=True, with_labels=True, **kwds):"""Draw the graph G using Matplotlib.Draw the graph with Matplotlib with options for node positions,labeling, titles, and many other drawing features.See draw() for simple drawing without labels or axes.Parameters----------G : graphA networkx graphpos : dictionary, optionalA dictionary with nodes as keys and positions as values.If not specified a spring layout positioning will be computed.See :py:mod:`networkx.drawing.layout` for functions thatcompute node positions.arrows : bool, optional (default=True)For directed graphs, if True draw arrowheads.Note: Arrows will be the same color as edges.arrowstyle : str, optional (default='-|>')For directed graphs, choose the style of the arrowsheads.See :py:class: `matplotlib.patches.ArrowStyle` for moreoptions.arrowsize : int, optional (default=10)For directed graphs, choose the size of the arrow head head's length andwidth. See :py:class: `matplotlib.patches.FancyArrowPatch` for attribute`mutation_scale` for more info.with_labels : bool, optional (default=True)Set to True to draw labels on the nodes.ax : Matplotlib Axes object, optionalDraw the graph in the specified Matplotlib axes.nodelist : list, optional (default G.nodes())Draw only specified nodesedgelist : list, optional (default=G.edges())Draw only specified edgesnode_size : scalar or array, optional (default=300)Size of nodes. If an array is specified it must be thesame length as nodelist.node_color : color or array of colors (default='#1f78b4')Node color. Can be a single color or a sequence of colors with the samelength as nodelist. Color can be string, or rgb (or rgba) tuple offloats from 0-1. If numeric values are specified they will bemapped to colors using the cmap and vmin,vmax parameters. Seematplotlib.scatter for more details.node_shape : string, optional (default='o')The shape of the node. Specification is as matplotlib.scattermarker, one of 'so^>v<dph8'.alpha : float, optional (default=None)The node and edge transparencycmap : Matplotlib colormap, optional (default=None)Colormap for mapping intensities of nodesvmin,vmax : float, optional (default=None)Minimum and maximum for node colormap scalinglinewidths : [None | scalar | sequence]Line width of symbol border (default =1.0)width : float, optional (default=1.0)Line width of edgesedge_color : color or array of colors (default='k')Edge color. Can be a single color or a sequence of colors with the samelength as edgelist. Color can be string, or rgb (or rgba) tuple offloats from 0-1. If numeric values are specified they will bemapped to colors using the edge_cmap and edge_vmin,edge_vmax parameters.edge_cmap : Matplotlib colormap, optional (default=None)Colormap for mapping intensities of edgesedge_vmin,edge_vmax : floats, optional (default=None)Minimum and maximum for edge colormap scalingstyle : string, optional (default='solid')Edge line style (solid|dashed|dotted,dashdot)labels : dictionary, optional (default=None)Node labels in a dictionary keyed by node of text labelsfont_size : int, optional (default=12)Font size for text labelsfont_color : string, optional (default='k' black)Font color stringfont_weight : string, optional (default='normal')Font weightfont_family : string, optional (default='sans-serif')Font familylabel : string, optionalLabel for graph legendNotes-----For directed graphs, arrows are drawn at the head end. Arrows can beturned off with keyword arrows=False.Examples-------->>> G = nx.dodecahedral_graph()>>> nx.draw(G)>>> nx.draw(G, pos=nx.spring_layout(G)) # use spring layout>>> import matplotlib.pyplot as plt>>> limits = plt.axis('off') # turn of axisAlso see the NetworkX drawing examples athttps://networkx.github.io/documentation/latest/auto_examples/index.htmlSee Also--------draw()draw_networkx_nodes()draw_networkx_edges()draw_networkx_labels()draw_networkx_edge_labels()"""try:import matplotlib.pyplot as pltexcept ImportError:raise ImportError("Matplotlib required for draw()")except RuntimeError:print("Matplotlib unable to open display")raiseif pos is None:pos = nx.drawing.spring_layout(G) # default to spring layoutnode_collection = draw_networkx_nodes(G, pos, **kwds)edge_collection = draw_networkx_edges(G, pos, arrows=arrows, **kwds)if with_labels:draw_networkx_labels(G, pos, **kwds)plt.draw_if_interactive()
Python+NetworkX画图的nx.draw_networkx(函数详解)相关推荐
- NetworkX画图:nx.draw_networkx(函数详解)
NetworkX画图:nx.draw_networkx(函数详解) draw_networkx(G, pos=None, arrows=True, with_labels=True, **kwds) ...
- python中zip的使用_浅谈Python中的zip()与*zip()函数详解
前言 1.实验环境: Python 3.6: 2.示例代码地址:下载示例: 3.本文中元素是指列表.元组.字典等集合类数据类型中的下一级项目(可能是单个元素或嵌套列表). zip(*iterables ...
- python中argparse模块关于 parse_args() 函数详解(全)
目录 前言 1. 函数讲解 2. 基本用法 3. 实战讲解 前言 原理:命令行解析使用argparse包 作用:命令行传参赋值 可用在机器学习深度学习 或者 脚本运行等 了解这个函数需要了解其背后的原 ...
- 数字的可视化:python画图之散点图sactter函数详解
最近开始学习Python编程,遇到scatter函数,感觉里面的参数不知道什么意思于是查资料,最后总结如下: 1.scatter函数原型 2.其中散点的形状参数marker如下: 3.其中颜色参数c如 ...
- 【Python】sklearn 中的 make_blobs() 函数详解
文章目录 一.介绍 二.函数的使用 一.介绍 make_blobs() 是 sklearn.datasets中的一个函数. 主要是产生聚类数据集,产生一个数据集和相应的标签. 函数的源代码如下: de ...
- 【Python入门】Python数学math模块55个函数详解
Python math 模块提供了许多对浮点数的数学运算函数.主要包括以下几个部分 数论与表示函数 幂函数与对数函数 三角函数 角度转换 双曲函数 特殊函数 常量 import math print( ...
- python中的range()函数详解
首先说明一下range()函数: 在python中range()函数是一个内建函数:这个内建函数用起来还是很方便的,只不过有些细节的地方我在这里写一写!供大家交流! (1)记录如下: 既然上面的明白了 ...
- python中zip什么意思_浅谈Python中的zip()与*zip()函数详解 python的zip函数加上一个*号,是什么含义...
python 当中的zip( )函数到底是干嘛的?你越来越善解人意,就没人在意你的委屈和脾气. zip([1,2,3],['a','b','c']) 结果是 [(1, 'a'), (2, 'b'), ...
- python获取系统时间(时间函数详解)
转自:https://www.weidianyuedu.com/ import time print time.time() 输出的结果是: 1279578704.6725271 但是这样是一连串的数 ...
最新文章
- ubuntu 14.04 双显卡安装NVIDIA GPU驱动+CUDA+编译配置caffe
- matlab怎么连接服务器,matlab安装小坑----连接不上服务器
- Android中RelativeLayout各个属性的含义
- GARFIELD@01-13-2005
- apache Apache winnt_accept: Asynchronous AcceptEx failed 错误的解决
- 计算机网络知识点总结谢,《计算机网络基础》复习提纲_谢(5)版-课堂教案
- java int a=b指向_java里int a=3,给a赋值的时候,是给它3的地址,还是直接赋值二进制3?...
- ANSI SQL标准和准则
- Delphi使用ReportMachine制作小计和总计报表
- windows 固定桌面图标
- 访问图片出现403的解决办法
- 可视化——Excel2进阶
- ROM制作工具V1.0.0.22版本全新推出
- 1.Redis客户端
- PHP折算,PHP实现货币换算的方法_PHP
- Browser历险记】认识Browser浏览器
- python语言与蟒蛇_1、python语言是一种“大蟒蛇语言‘’,但是python语言却和蟒蛇没有任何关系_学小易找答案...
- 【JavaIO流】JavaIO中的常用处理流
- PMP计算(带例题)
- metaRTC(yangwebrtc)-中国人自己的webrtc