| plot-methods {Rgraphviz} | R Documentation |
A plot method for graph objects.
'graph': plot(x, y, ..., subGList=list(), attrs=list(),
nodeAttrs=list(), edgeAttrs=list(), xlab="", ylab="", main=NULL,
sub=sub, recipEdges=c("combined", "distinct"))
'Ragraph': plot(x, y, ..., xlab="", ylab="", main=NULL,
sub=sub, drawNode=drawAgNode, nodeAttrs=list(), edgeAttrs=list())
graph object to plotdot,
neato, twopi, circo, and
fdp. The default is dotgraph object to be plotted. If provided, these subgraphs
will be clustered visually. If not provided, no clusters will be used.drawAgNodeagopen
The first plot method in the usage section corresponds to the
graph class in the graph package. It will convert the
graph object into an object of class Ragraph by using
Graphviz to perform the layout. Then it will call the plot method for
Ragraph. The plot.graph method is nothing more then a
wrapper that calls agopen and plot.Ragraph.
The second plot method in the usage section is for the
Ragraph class, which describes a Graphviz structure of a
graph. This method will extract necessary information from the object
and use it to plot the graph.
Users can specify arbitrary drawing functions for the nodes of the
Ragraph with the drawNode argument, although caution is
urged. The default drawing function for
all nodes is drawAgNode, which will draw a basic circle,
ellipse or rectangle according to the layout specifications for each
node. If supplying a custom function, users are encouraged to look at
the code of this function for a more clear picture of the information
required to properly draw a node. Users can specify either one
custom function to be used for all nodes or a list (where length is
equal to the nubmer of nodes) of functions where the Nth element in
the list provides the drawing function for the Nth node, and every
function will take four parameters - the first is an object of class
AgNode representing the node itself and the second is an object
of class xyPoint representing the upper right corner of
the Graphviz plotting region (where the lower left is 0,0).
The third parameter, attrs is a node attribute list and
represents post-layout attribute changes where the user wants to
override values present in the layout. The last argument,
radConv is a divisor to the radius and is used to convert from
Graphviz units to R plotting units. Outside of the first
argument, the rest of these (particularly radConv which
generally shouldn't be specifically set) do not need to be set by the
user, but any drawing function must have them as parameters.
The attrs list requires a particular format. It must be of
length 3 with names graph, node, and edge. Each
of these elements themselves are lists - such that an element of
graph corresponds to a graph element. A full listing of
attributes and their possible settings is available at
http://www.research.att.com/~erg/graphviz/info/attrs.html. All
attribute values should be entered as character strings (even if the
requested value is to be otherwise).
The nodeAttrs list is used to specify attributes on a
particular node, instead of for all nodes. The format of this list is
such that the elements correspond to attributes (the name of the
element is used to note which attribute) and each element contains a
named vector. The names of the vector denote which nodes are having
this attribute set and the values in the vector specify the value.
The edgeAttrs list is identical in format to nodeAttrs.
However, the name of the edges is in a particular format where an edge
between x and y is named x~y. Note that even in an undirected
graph that x~y is not the same as y~x - the name must be
in the same order that the edge was defined as having.
The Ragraph object used for plotting
Jeff Gentry
# WHY DOES THIS NOT WORK IN CHECK? # V <- letters[1:10] # M <- 1:4 # g1 <- randomGraph(V, M, .2) # plot(g1)