R plot of a matrix of complex numbers -
i have matrix of complex values.
if issue command:
plot(mymatrix)
then shows on graphics device kind of scatterplot, x-axis labeled re(mymatrix) , y-axis im(mymatrix). shows information i'm looking for, can see distinct clusters, cannot see 1 column.
my questions :
- i assume there 1 point per matrix row. right ?
- how calculated re(mymatrix) each row vector ?
it not re(mymatrix[1,row]), seems mix of values of row vector. able these values, know how compute them r.
no, there 1 point each matrix element.
set.seed(42) mat <- matrix(complex(real = rnorm(16), imaginary = rlnorm(16)), 4) plot(mat) points(re(mat[1,1]), im(mat[1,1]), col = "red", pch = ".", cex = 5)
look red dot:
you'd same plot, if plotted vector instead of matrix, i.e., plot(c(mat))
.
this happens because plot.default
calls xy.coords
, function contains following code:
else if (is.complex(x)) { y <- im(x) x <- re(x) xlab <- paste0("re(", ylab, ")") ylab <- paste0("im(", ylab, ")") } else if (is.matrix(x) || is.data.frame(x)) {
this means, fact input complex takes priority on being matrix.
Comments
Post a Comment