plot-methods: Plot a graph object - methods

plot-methodsR Documentation

Plot a graph object - methods

Description

A plot method for graph objects.

Usage

## S4 method for signature 'graph,ANY'
plot(x, y, ..., name = "", subGList = list(), 
    attrs = list(), nodeAttrs = list(), edgeAttrs = list(), 
    recipEdges = c("combined", "distinct"))
## S4 method for signature 'Ragraph,ANY'
plot(x, y, edgeAttrs = list(), ..., main = NULL, 
    cex.main = NULL, col.main = "black", sub = NULL, cex.sub = NULL, 
    col.sub = "black", drawNode = drawAgNode, xlab, ylab, mai)

Arguments

x

The graph object to plot

y

The layout method to use: One of dot, neato, twopi, circo, and fdp. The default is dot

name

The name of the graph, passed to agopen

subGList

A list of subgraphs taken from the primary graph object to be plotted. If provided, these subgraphs will be clustered visually. If not provided, no clusters will be used.

attrs

A list of Graphviz attributes to be sent to the layout engine

nodeAttrs

A list of attributes for specific nodes

edgeAttrs

A list of attributes for specific edges

recipEdges

Determines how to draw reciprocating edges. See agopen

main, cex.main, col.main

Main label and graphic parameters for the plot

sub, cex.sub, col.sub

Subtitle and graphic parameters for the plot

drawNode

Function to draw the nodes. The default is drawAgNode

xlab

Label for the x axis of the plot

ylab

Label for the y axis of the plot

mai

Margins for plot

...

General commands to be sent to plot

details

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.

value

The Ragraph object used for plotting

author

Jeff Gentry

seealso

graphNEL-class, graph-class

Examples

#  WHY DOES THIS NOT WORK IN CHECK?
#  V <- letters[1:10]
#  M <- 1:4
#  g1 <- randomGraph(V, M, .2)
#  plot(g1)

kasperdanielhansen/Rgraphviz documentation built on Nov. 4, 2022, 4:14 a.m.