Learn R Programming

sna (version 0.3)

plot.matrix: Plot Matrices Using a Color/Intensity Grid

Description

Plots a matrix, m, associating the magnitude of the i,jth cell of m with the color of the i,jth cell of an nrow(m) by ncol(m) grid.

Usage

plot.matrix(m, labels=list(seq(1:dim(m)[1]), seq(1:dim(m)[2])), 
    drawlab=TRUE, diaglab=TRUE, ...)

Arguments

m
An input matrix
labels
A list containing the vectors of row and column labels (respectively)
drawlab
Add labels to the plot?
diaglab
Label the diagonal?
...
Additional arguments to plot

Value

  • None

Details

plot.matrix is particularly valuable for examining large adjacency matrices, whose structure can be non-obvious otherwise.

Examples

Run this code
#Plot a small adjacency matrix
plot.matrix(rgraph(5))

#Plot a much larger one
plot.matrix(rgraph(100),drawlab=F,diaglab=F)

Run the code above in your browser using DataLab