# Drawing graphs

##### Drawing graphs

The common bits of the three plotting functions
`plot.igraph`

, `tkplot`

and `rglplot`

are discussed in
this manual page

##### Details

There are currently three different functions in the igraph package which can draw graph in various ways:

`plot.igraph`

does simple non-interactive 2D plotting to R devices.
Actually it is an implementation of the `plot`

generic function,
so you can write `plot(graph)`

instead of
`plot.igraph(graph)`

. As it used the standard R devices it
supports every output format for which R has an output device. The
list is quite impressing: PostScript, PDF files, XFig files, SVG
files, JPG, PNG and of course you can plot to the screen as well using
the default devices, or the good-looking anti-aliased Cairo device.
See `plot.igraph`

for some more information.

`tkplot`

does interactive 2D plotting using the `tcltk`

package. It can only handle graphs of moderate size, a thousend
vertices is probably already too many. Some parameters of the plotted
graph can be changed interactively after issuing the `tkplot`

command: the position, color and size of the vertices and the color
and width of the edges. See `tkplot`

for details.
`rglplot`

is an experimental function to draw graphs in 3D
using OpenGL. See `rglplot`

for some more information.

Please also check the examples below.

##### concept

Visualization

##### How to specify graphical parameters

There are three ways to give values to the parameters described below, in section 'Parameters'. We give these three ways here in the order of their precedence.

The first method is to supply named arguments to the plotting commands:
`plot.igraph`

, `tkplot`

or
`rglplot`

. Parameters for vertices start with prefix
`vertex.`

`edge.`

`vertex.color`

,
whereas `edge.color`

sets the color of the edges. `layout`

gives the layout of the graphs.

The second way is to assign vertex, edge and graph attributes to the
graph. These attributes have now prefix, ie. the color of the vertices
is taken from the `color`

vertex attribute and the color of the
edges from the `color`

edge attribute. The layout of the graph is
given by the `layout`

graph attribute. (Always assuming that the
corresponding command argument is not present.) Setting vertex and
edge attributes are handy if you want to assign a given `save`

or in GraphML format with
`write.graph`

, so the graph will have the same look after
loading it again.

If a parameter is not given in the command line, and the corresponding
vertex/edge/graph attribute is also missing then the general igraph
parameters handled by `igraph.options`

are also
checked. Vertex parameters have prefix `vertex.`

`edge.`

`layout`

are prefixed with `plot`

If the value of a parameter is not specified by any of the three ways described here, its default valued is used, as given in the source code.

Different parameters can have different type, eg. vertex colors can be
given as a character vector with color names, or as an integer vector
with the color numbers from the current palette. Different types are
valid for different parameters, this is discussed in detail in the
next section. It is however always true that the parameter can always
be a function object in which it will be called with the graph as its
single argument to get the *not*
be called again...)

*Documentation reproduced from package igraph, version 0.6.5-2, License: GPL (>= 2)*