#NEWLINE# def draw_networkx_nodes( G , pos , nodelist = None , node_size = 300 , node_color = 'r' , node_shape = 'o' , alpha = 1.0 , cmap = None , vmin = None , vmax = None , ax = None , linewidth = None , zorder = None , **kwds ) : #NEWLINE# #INDENT# "Draw the nodes of the graph G.\n\n    This draws only the nodes of the graph G.\n\n    Parameters\n    ----------\n    G : graph\n       A networkx graph\n\n    pos : dictionary\n       A dictionary with nodes as keys and positions as values.\n       If not specified a spring layout positioning will be computed.\n       See networkx.layout for functions that compute node positions.\n\n    ax : Matplotlib Axes object, optional\n       Draw the graph in the specified Matplotlib axes.\n\n    nodelist: list, optional\n       Draw only specified nodes (default G.nodes())\n\n    edgelist: list\n       Draw only specified edges(default=G.edges())\n\n    node_size: scalar or array\n       Size of nodes (default=300).  If an array is specified it must be the\n       same length as nodelist.\n\n    node_color: color string, or array of floats\n       Node color. Can be a single color format string (default='r'),\n       or a  sequence of colors with the same length as nodelist.\n       If numeric values are specified they will be mapped to\n       colors using the cmap and vmin,vmax parameters.  See\n       matplotlib.scatter for more details.\n\n    node_shape:  string\n       The shape of the node.  Specification is as matplotlib.scatter\n       marker, one of 'so^>v<dph8' (default='o').\n\n    alpha: float\n       The node transparency (default=1.0)\n\n    cmap: Matplotlib colormap\n       Colormap for mapping intensities of nodes (default=None)\n\n    vmin,vmax: floats\n       Minimum and maximum for node colormap scaling (default=None)\n\n    width`: float\n       Line width of edges (default =1.0)\n\n\n    Notes\n    -----\n    Any keywords not listed above are passed through to Matplotlib's\n    scatter function.\n\n    Examples\n    --------\n    >>> G=nx.dodecahedral_graph()\n    >>> nodes=nx.draw_networkx_nodes(G,pos=nx.spring_layout(G))\n\n    Also see the NetworkX drawing examples at\n    http://networkx.lanl.gov/gallery.html\n\n    See Also\n    --------\n    draw()\n    draw_networkx()\n    draw_networkx_edges()\n    draw_networkx_labels()\n    draw_networkx_edge_labels()\n\n\n\n    " #NEWLINE# try : #NEWLINE# #INDENT# import matplotlib.pylab as pylab #NEWLINE# import numpy #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# raise ImportError ( 'Matplotlib required for draw()' ) #NEWLINE# #UNINDENT# except RuntimeError : #NEWLINE# #INDENT# print ( 'Matplotlib unable to open display' ) #NEWLINE# raise #NEWLINE# #UNINDENT# if ( zorder is None ) : #NEWLINE# #INDENT# zorder = 2 #NEWLINE# #UNINDENT# if ( ax is None ) : #NEWLINE# #INDENT# ax = pylab . gca ( ) #NEWLINE# #UNINDENT# if ( nodelist is None ) : #NEWLINE# #INDENT# nodelist = G . nodes ( ) #NEWLINE# #UNINDENT# if ( ( not nodelist ) or ( len ( nodelist ) == 0 ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# xy = numpy . asarray ( [ pos [ v ] for v in nodelist ] ) #NEWLINE# #UNINDENT# except KeyError as e : #NEWLINE# #INDENT# raise nx . NetworkXError ( ( 'Node %s has no position.' % e ) ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise nx . NetworkXError ( 'Bad value in node positions.' ) #NEWLINE# #UNINDENT# syms = { #NEWLINE# #INDENT# 's' : ( 4 , ( math . pi / 4.0 ) , 0 ) , #NEWLINE# 'o' : ( 0 , 0 , 3 ) , #NEWLINE# '^' : ( 3 , 0 , 0 ) , #NEWLINE# '>' : ( 3 , ( math . pi / 2.0 ) , 0 ) , #NEWLINE# 'v' : ( 3 , math . pi , 0 ) , #NEWLINE# '<' : ( 3 , ( ( 3 * math . pi ) / 2.0 ) , 0 ) , #NEWLINE# 'd' : ( 4 , 0 , 0 ) , #NEWLINE# 'p' : ( 5 , 0 , 0 ) , #NEWLINE# 'h' : ( 6 , 0 , 0 ) , #NEWLINE# '8' : ( 8 , 0 , 0 ) , #NEWLINE# '+' : ( 4 , 0 , 0 ) , #NEWLINE# 'x' : ( 4 , ( math . pi / 4.0 ) , 0 ) , #NEWLINE# #UNINDENT# } #NEWLINE# temp_x = [ p [ 0 ] for p in list ( pos . values ( ) ) ] #NEWLINE# temp_y = [ p [ 1 ] for p in list ( pos . values ( ) ) ] #NEWLINE# minx = np . amin ( temp_x ) #NEWLINE# maxx = np . amax ( temp_x ) #NEWLINE# miny = np . amin ( temp_y ) #NEWLINE# maxy = np . amax ( temp_y ) #NEWLINE# w = max ( ( maxx - minx ) , 1.0 ) #NEWLINE# h = max ( ( maxy - miny ) , 1.0 ) #NEWLINE# area2radius = ( lambda a : math . sqrt ( ( ( ( a * w ) * h ) / ( ( ( ( ( ( ax . figure . get_figheight ( ) * ax . figure . get_figwidth ( ) ) * ax . figure . dpi ) * ax . figure . dpi ) * math . pi ) * 0.75 ) * 0.75 ) ) ) ) #NEWLINE# if cb . iterable ( node_size ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# vals = list ( node_size . values ( ) ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# vals = node_size #NEWLINE# #UNINDENT# node_size = dict ( list ( zip ( nodelist , list ( map ( area2radius , vals ) ) ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# node_size = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } . fromkeys ( nodelist , area2radius ( node_size ) ) #NEWLINE# #UNINDENT# for n in node_size : #NEWLINE# #INDENT# if ( node_size [ n ] == 0.0 ) : #NEWLINE# #INDENT# node_size [ n ] = 1e-05 #NEWLINE# #UNINDENT# #UNINDENT# if ( cmap is None ) : #NEWLINE# #INDENT# cmap = cm . get_cmap ( mpl . rcParams [ 'image.cmap' ] ) #NEWLINE# #UNINDENT# n_colors = get_color_dict ( node_color , nodelist , vmin , vmax , cmap ) #NEWLINE# sym = syms [ node_shape ] #NEWLINE# ( numsides , rotation , symstyle ) = syms [ node_shape ] #NEWLINE# node_patches = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for n in nodelist : #NEWLINE# #INDENT# if ( symstyle == 0 ) : #NEWLINE# #INDENT# node_patches [ n ] = patches . RegularPolygon ( pos [ n ] , numsides , orientation = rotation , radius = node_size [ n ] , facecolor = n_colors [ n ] , edgecolor = 'k' , alpha = alpha , linewidth = linewidth , transform = ax . transData , zorder = zorder ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( symstyle == 3 ) : #NEWLINE# #INDENT# node_patches [ n ] = patches . Circle ( pos [ n ] , radius = node_size [ n ] , facecolor = n_colors [ n ] , edgecolor = 'k' , alpha = alpha , linewidth = linewidth , transform = ax . transData , zorder = zorder ) #NEWLINE# #UNINDENT# #UNINDENT# ax . add_patch ( node_patches [ n ] ) #NEWLINE# #UNINDENT# temp_x = xy [ : , 0 ] #NEWLINE# temp_y = xy [ : , 1 ] #NEWLINE# minx = np . amin ( temp_x ) #NEWLINE# maxx = np . amax ( temp_x ) #NEWLINE# miny = np . amin ( temp_y ) #NEWLINE# maxy = np . amax ( temp_y ) #NEWLINE# w = ( maxx - minx ) #NEWLINE# h = ( maxy - miny ) #NEWLINE# ( padx , pady ) = ( ( 0.05 * w ) , ( 0.05 * h ) ) #NEWLINE# corners = ( ( ( minx - padx ) , ( miny - pady ) ) , ( ( maxx + padx ) , ( maxy + pady ) ) ) #NEWLINE# ax . update_datalim ( corners ) #NEWLINE# ax . autoscale_view ( ) #NEWLINE# ax . set_aspect ( 'equal' ) #NEWLINE# return node_patches