to_latex_raw#

to_latex_raw(G, pos='pos', tikz_options='', default_node_options='', node_options='node_options', node_label='label', default_edge_options='', edge_options='edge_options', edge_label='label', edge_label_options='edge_label_options')[source]#

Return a string of the LaTeX/TikZ code to draw G

This function produces just the code for the tikzpicture without any enclosing environment.

Parameters:
GNetworkX graph

The NetworkX graph to be drawn

posstring or dict (default “pos”)

The name of the node attribute on G that holds the position of each node. Positions can be sequences of length 2 with numbers for (x,y) coordinates. They can also be strings to denote positions in TikZ style, such as (x, y) or (angle:radius). If a dict, it should be keyed by node to a position. If an empty dict, a circular layout is computed by TikZ.

tikz_optionsstring

The tikzpicture options description defining the options for the picture. Often large scale options like [scale=2].

default_node_optionsstring

The draw options for a path of nodes. Individual node options override these.

node_optionsstring or dict

The name of the node attribute on G that holds the options for each node. Or a dict keyed by node to a string holding the options for that node.

node_labelstring or dict

The name of the node attribute on G that holds the node label (text) displayed for each node. If the attribute is “” or not present, the node itself is drawn as a string. LaTeX processing such as "$A_1$" is allowed. Or a dict keyed by node to a string holding the label for that node.

default_edge_optionsstring

The options for the scope drawing all edges. The default is “[-]” for undirected graphs and “[->]” for directed graphs.

edge_optionsstring or dict

The name of the edge attribute on G that holds the options for each edge. If the edge is a self-loop and "loop" not in edge_options the option “loop,” is added to the options for the self-loop edge. Hence you can use “[loop above]” explicitly, but the default is “[loop]”. Or a dict keyed by edge to a string holding the options for that edge.

edge_labelstring or dict

The name of the edge attribute on G that holds the edge label (text) displayed for each edge. If the attribute is “” or not present, no edge label is drawn. Or a dict keyed by edge to a string holding the label for that edge.

edge_label_optionsstring or dict

The name of the edge attribute on G that holds the label options for each edge. For example, “[sloped,above,blue]”. The default is no options. Or a dict keyed by edge to a string holding the label options for that edge.

Returns:
latex_codestring

The text string which draws the desired graph(s) when compiled by LaTeX.