File: plotMat.Rd

package info (click to toggle)
r-cran-blockmodeling 1.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 912 kB
  • sloc: ansic: 2,024; f90: 952; sh: 13; makefile: 5
file content (388 lines) | stat: -rw-r--r-- 14,791 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.crit.fun.R, R/plot.mat.nm.R,
%   R/plot.opt.more.par.R, R/plot.opt.more.par.mode.R, R/plot.opt.par.R,
%   R/plot.opt.par.mode.R, R/plotMat.R
\encoding{UTF-8}
\name{plot.critFun}
\alias{plot.critFun}
\alias{plot.crit.fun}
\alias{plotMatNm}
\alias{plot.optMorePar}
\alias{plot.opt.more.par}
\alias{plot.optMoreParMode}
\alias{plot.opt.more.par.mode}
\alias{plot.optPar}
\alias{plot.opt.par}
\alias{plot.optParMode}
\alias{plot.opt.par.mode}
\alias{plotMat}
\alias{plotArray}
\alias{plot.mat}
\title{Functions for plotting a partitioned matrix (representing the network)}
\usage{
\method{plot}{critFun}(x, main = NULL, ...)

\method{plot}{crit.fun}(x, main = NULL, ...)

plotMatNm(
  M = x,
  x = M,
  ...,
  main.title = NULL,
  title.row = "Row normalized",
  title.col = "Column normalized",
  main.title.line = -2,
  par.set = list(mfrow = c(1, 2))
)

\method{plot}{optMorePar}(x, main = NULL, which = 1, ...)

\method{plot}{opt.more.par}(x, main = NULL, which = 1, ...)

\method{plot}{optMoreParMode}(x, main = NULL, which = 1, ...)

\method{plot}{opt.more.par.mode}(x, main = NULL, which = 1, ...)

\method{plot}{optPar}(x, main = NULL, which = 1, ...)

\method{plot}{opt.par}(x, main = NULL, which = 1, ...)

\method{plot}{optParMode}(x, main = NULL, which = 1, ...)

\method{plot}{opt.par.mode}(x, main = NULL, which = 1, ...)

plotMat(
  x = M,
  clu = NULL,
  orderClu = FALSE,
  M = x,
  ylab = "",
  xlab = "",
  main = NULL,
  print.val = !length(table(M)) <= 2,
  print.0 = FALSE,
  plot.legend = !print.val && !length(table(M)) <= 2,
  print.legend.val = "out",
  print.digits.legend = 2,
  print.digits.cells = 2,
  print.cells.mf = NULL,
  outer.title = FALSE,
  title.line = ifelse(outer.title, -1.5, 7),
  mar = c(0.5, 7, 8.5, 0) + 0.1,
  cex.val = "default",
  val.y.coor.cor = 0,
  val.x.coor.cor = 0,
  cex.legend = 1,
  legend.title = "Legend",
  cex.axes = "default",
  print.axes.val = NULL,
  print.x.axis.val = !is.null(colnames(M)),
  print.y.axis.val = !is.null(rownames(M)),
  x.axis.val.pos = 1.01,
  y.axis.val.pos = -0.01,
  cex.main = par()$cex.main,
  cex.lab = par()$cex.lab,
  yaxis.line = -1.5,
  xaxis.line = -1,
  legend.left = 0.4,
  legend.up = 0.03,
  legend.size = 1/min(dim(M)),
  legend.text.hor.pos = 0.5,
  par.line.width = 3,
  par.line.width.newSet = par.line.width[1] * 2,
  par.line.col = "blue",
  par.line.col.newSet = "red",
  IM.dens = NULL,
  IM = NULL,
  wnet = NULL,
  wIM = NULL,
  use.IM = length(dim(IM)) == length(dim(M)) | !is.null(wIM),
  dens.leg = c(null = 100, nul = 100),
  blackdens = 70,
  plotLines = FALSE,
  frameMatrix = TRUE,
  x0ParLine = -0.1,
  x1ParLine = 1,
  y0ParLine = 0,
  y1ParLine = 1.1,
  colByUnits = NULL,
  colByRow = NULL,
  colByCol = NULL,
  mulCol = 2,
  joinColOperator = "+",
  colTies = FALSE,
  maxValPlot = NULL,
  printMultipliedMessage = TRUE,
  replaceNAdiagWith0 = TRUE,
  colLabels = FALSE,
  MplotValues = NULL,
  ...
)

plotArray(
  x = M,
  M = x,
  IM = NULL,
  ...,
  main.title = NULL,
  main.title.line = -2,
  mfrow = NULL
)

\method{plot}{mat}(
  x = M,
  clu = NULL,
  orderClu = FALSE,
  M = x,
  ylab = "",
  xlab = "",
  main = NULL,
  print.val = !length(table(M)) <= 2,
  print.0 = FALSE,
  plot.legend = !print.val && !length(table(M)) <= 2,
  print.legend.val = "out",
  print.digits.legend = 2,
  print.digits.cells = 2,
  print.cells.mf = NULL,
  outer.title = FALSE,
  title.line = ifelse(outer.title, -1.5, 7),
  mar = c(0.5, 7, 8.5, 0) + 0.1,
  cex.val = "default",
  val.y.coor.cor = 0,
  val.x.coor.cor = 0,
  cex.legend = 1,
  legend.title = "Legend",
  cex.axes = "default",
  print.axes.val = NULL,
  print.x.axis.val = !is.null(colnames(M)),
  print.y.axis.val = !is.null(rownames(M)),
  x.axis.val.pos = 1.01,
  y.axis.val.pos = -0.01,
  cex.main = par()$cex.main,
  cex.lab = par()$cex.lab,
  yaxis.line = -1.5,
  xaxis.line = -1,
  legend.left = 0.4,
  legend.up = 0.03,
  legend.size = 1/min(dim(M)),
  legend.text.hor.pos = 0.5,
  par.line.width = 3,
  par.line.width.newSet = par.line.width[1] * 2,
  par.line.col = "blue",
  par.line.col.newSet = "red",
  IM.dens = NULL,
  IM = NULL,
  wnet = NULL,
  wIM = NULL,
  use.IM = length(dim(IM)) == length(dim(M)) | !is.null(wIM),
  dens.leg = c(null = 100, nul = 100),
  blackdens = 70,
  plotLines = FALSE,
  frameMatrix = TRUE,
  x0ParLine = -0.1,
  x1ParLine = 1,
  y0ParLine = 0,
  y1ParLine = 1.1,
  colByUnits = NULL,
  colByRow = NULL,
  colByCol = NULL,
  mulCol = 2,
  joinColOperator = "+",
  colTies = FALSE,
  maxValPlot = NULL,
  printMultipliedMessage = TRUE,
  replaceNAdiagWith0 = TRUE,
  colLabels = FALSE,
  MplotValues = NULL,
  ...
)
}
\arguments{
\item{x}{A result from a corresponding function or a matrix or similar object representing a network.}

\item{main}{Main title.}

\item{\dots}{Additional arguments to \code{plot.default} for \code{plotMat} and also to \code{plotMat} for other functions.}

\item{M}{A matrix or similar object representing a network - either \code{x} or \code{M} must be supplied - both are here to make the code compatible with generic and with older functions.}

\item{main.title}{Main title in \code{plotArray} version.}

\item{title.row}{Title for the row-normalized matrix in nm version}

\item{title.col}{Title for the column-normalized matrix in nm version}

\item{main.title.line}{The line in which main title is printed in \code{plotArray} version.}

\item{par.set}{A list of possible plotting parameters (to \code{par}) to be used in nm version}

\item{which}{Which (if there are more than one) of optimal solutions to plot.}

\item{clu}{A partition. Each unique value represents one cluster. If the network is one-mode,
then this should be a vector, else a list of vectors, one for each mode/set.}

\item{orderClu}{Should the partition be ordered before plotting. \code{FALSE} by default. If \code{TRUE}, \code{\link{orderClu}} is used (using default arguments) to order the clusters in a partition in "decreasing" (see \code{\link{orderClu}} for interpretation) order.}

\item{ylab}{Label for y axis.}

\item{xlab}{Label for x axis.}

\item{print.val}{Should the values be printed in the matrix.}

\item{print.0}{If \code{print.val = TRUE} Should the 0s be printed in the matrix.}

\item{plot.legend}{Should the legend for shades be plotted.}

\item{print.legend.val}{Should the values be printed in the legend.}

\item{print.digits.legend}{The number of digits that should appear in the legend.}

\item{print.digits.cells}{The number of digits that should appear in the cells (of the matrix and/or legend).}

\item{print.cells.mf}{If not \code{NULL}, the above argument is ignored, the cell values are printed as the cell are multiplied by this factor and rounded.}

\item{outer.title}{Should the title be printed on the 'inner' or 'outer' margin of the plot, default is 'inner' margin.}

\item{title.line}{The line (from the top) where the title should be printed. The suitable values depend heavily on the displayed type.}

\item{mar}{A numerical vector of the form \code{c(bottom, left, top, right)} which gives the lines of margin to be specified on the four sides of the plot.
The R default for ordinary  plots is \code{c(5, 4, 4, 2) + 0.1}, while this function default is \code{c(0.5, 7, 8.5, 0) + 0.1}.}

\item{cex.val}{The size of the values printed. The default is \code{10 / 'number of units'}.}

\item{val.y.coor.cor}{Correction for centering the values in the squares in y direction.}

\item{val.x.coor.cor}{Correction for centering the values in the squares in x direction.}

\item{cex.legend}{Size of the text in the legend.}

\item{legend.title}{The title of the legend.}

\item{cex.axes}{Size of the characters in axes. Default makes the cex so small that all categories can be printed.}

\item{print.axes.val}{Should the axes values be printed. Default prints each axis if \code{rownames} or \code{colnames} is not \code{NULL}.}

\item{print.x.axis.val}{Should the x axis values be printed. Default prints each axis if \code{rownames} or \code{colnames} is not \code{NULL}.}

\item{print.y.axis.val}{Should the y axis values be printed. Default prints each axis if \code{rownames} or \code{colnames} is not \code{NULL}.}

\item{x.axis.val.pos}{The x coordinate of the y axis values.}

\item{y.axis.val.pos}{The y coordinate of the x axis values.}

\item{cex.main}{Size of the text in the main title.}

\item{cex.lab}{Size of the text in matrix.}

\item{yaxis.line}{The position of the y axis (the argument 'line').}

\item{xaxis.line}{The position of the x axis (the argument 'line').}

\item{legend.left}{How much left should the legend be from the matrix.}

\item{legend.up}{How much up should the legend be from the matrix.}

\item{legend.size}{Relative legend size.}

\item{legend.text.hor.pos}{Horizontal position of the legend text (bottom) - 0 = bottom, 0.5 = middle,...}

\item{par.line.width}{The width of the line that separates  the partitions.}

\item{par.line.width.newSet}{The width of the line that separates  that separates the sets/modes - only used when \code{clu} is a list and \code{par.line.width} has length 1.}

\item{par.line.col}{The color of the line that separates the partitions.}

\item{par.line.col.newSet}{The color of the line that separates  that separates the sets/modes - only used when \code{clu} is a list and \code{par.line.col} has length 1.}

\item{IM.dens}{The density of shading lines in each block.}

\item{IM}{The image (as obtained  with \code{critFunC}) of the blockmodel. \code{dens.leg} is used to translate this image into \code{IM.dens}.}

\item{wnet}{Specifies which matrix (if more) should be plotted  - used if \code{M} is an array.}

\item{wIM}{Specifies which \code{IM} (if more) should be used for plotting. The default value is set to \code{wnet}) - used if \code{IM} is an array.}

\item{use.IM}{Specifies if \code{IM} should be used for plotting.}

\item{dens.leg}{It is used to translate the \code{IM} into \code{IM.dens}.}

\item{blackdens}{At which density should the values on dark colors  of lines be printed in white.}

\item{plotLines}{Should the lines in the matrix be printed. The default value is set to \code{FALSE}, best set to \code{TRUE} for very small networks.}

\item{frameMatrix}{Should the matrix be framed (if \code{plotLines} is \code{FALSE}). The default value is set to \code{TRUE}.}

\item{x0ParLine}{Coordinates for lines separating clusters.}

\item{x1ParLine}{Coordinates for lines separating clusters.}

\item{y0ParLine}{Coordinates for lines separating clusters.}

\item{y1ParLine}{Coordinates for lines separating clusters.}

\item{colByUnits}{Coloring units. It should be a vector of unit length.}

\item{colByRow}{Coloring units by rows. It should be a vector of unit length.}

\item{colByCol}{Coloring units by columns. It should be a vector of unit length.}

\item{mulCol}{Multiply color when joining with row, column. Only used when when \code{colByUnits} is not \code{NULL}.}

\item{joinColOperator}{Function to join \code{colByRow} and \code{colByCol}. The default value is set to \code{"+"}.}

\item{colTies}{If \code{TRUE}, ties are colored, if \code{FALSE}, 0-ties are colored.}

\item{maxValPlot}{The value to use as a maximum when computing colors (ties with maximal positive value are plotted  as black).}

\item{printMultipliedMessage}{Should the message '* all values in cells were multiplied by' be printed on the plot. The default value is set to \code{TRUE}.}

\item{replaceNAdiagWith0}{If \code{replaceNAdiagWith0 = TRUE} Should the \code{NA} values on the diagonal of a matrix be replaced with 0s.}

\item{colLabels}{Should the labels of units be colored. If \code{FALSE}, these are not colored, if \code{TRUE}, they are colored with colors of clusters as defined by palette.
This can be also a vector of colors (or integers) for one-mode networks or a list of two such vectors for two-mode networks.}

\item{MplotValues}{A matrix to strings to plot in cells. Only to be used if other values than those in the original matrix (\code{x} or \code{M} arguments) should be used. Defaults to \code{NULL}, in which case the valued from original matrix are plotted (if this is not prevented by some other arguments). Overrides all other arguments that deal with cell values (e.g. \code{print.digits.cells}). Sets \code{print.val} to \code{TRUE} and \code{plot.legend} to \code{FALSE}.}

\item{mfrow}{\code{mfrow} Argument to \code{par} - number of row and column plots to be plotted on one figure.}
}
\value{
The functions are used for their side effect - plotting.
}
\description{
The main function \code{plot.mat} or \code{plotMat} plots a (optionally partitioned) matrix.
If the matrix is partitioned, the rows and columns of the matrix are rearranged according to the partitions.
Other functions are only wrappers for \code{plot.mat} or \code{plotMat} for convenience when plotting the results of the corresponding functions.
The \code{plotMatNm} plots two matrices based on M, normalized by rows and columns, next to each other. The \code{plotArray} plots an array. \code{plot.mat.nm} has been replaced by \code{plotMatNm}.
}
\examples{
# Generation of the network
n <- 20
net <- matrix(NA, ncol = n, nrow = n)
clu <- rep(1:2, times = c(5, 15))
tclu <- table(clu)
net[clu == 1, clu == 1] <- rnorm(n = tclu[1] * tclu[1], mean = 0, sd = 1)
net[clu == 1, clu == 2] <- rnorm(n = tclu[1] * tclu[2], mean = 4, sd = 1)
net[clu == 2, clu == 1] <- rnorm(n = tclu[2] * tclu[1], mean = 0, sd = 1)
net[clu == 2, clu == 2] <- rnorm(n = tclu[2] * tclu[2], mean = 0, sd = 1)

# Ploting the network
plotMat(M = net, clu = clu, print.digits.cells = 3)
class(net) <- "mat"
plot(net, clu = clu)
# See corresponding functions for examples for other ploting
# functions
# presented, that are essentially only the wrappers for "plot.max"
}
\references{
\enc{Žiberna, A.}{Ziberna, A.} (2007). Generalized Blockmodeling of Valued Networks. Social Networks, 29(1), 105-126. doi: 10.1016/j.socnet.2006.04.002

\enc{Žiberna, A.}{Ziberna, A.} (2008). Direct and indirect approaches to blockmodeling of valued networks in terms of regular equivalence. Journal of Mathematical Sociology, 32(1), 57-84. doi: 10.1080/00222500701790207
}
\seealso{
\code{\link{critFunC}}, \code{\link{optRandomParC}}
}
\author{
\enc{Aleš Žiberna}{Ales Ziberna}
}
\keyword{graphs}
\keyword{hplot}