Help plotting recurrence matrix

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Help plotting recurrence matrix

l.handke
Hi everyone,

 

I am trying to plot a recurrence matrix (package: nonlinearTseries).

 

This is my command, which gives the plot as found in the attached image
(example 1):

 

Team1 <- read.delim("Team1.txt", header =TRUE)

Team1_plot <- rqa(time.series = Team1$Kat5, embedding.dim = 1, time.lag = 1,

                radius = 0.1,lmin =2, vmin =2, distanceToBorder = 2, save.RM
= TRUE,

                do.plot = FALSE )

 

RP <- Team1_plot$recurrence.matrix

image (RP)

 

My first problem

 

1. I cannot change the labeling of the axis limits

 

While this command helps rotate the datapoints WITHIN the plot as desired
(example 2):

 

image(t(RP[,ncol(RP):1])) # rotate matrix by 90° and plot

 

the labeling of the axes is still wrong (the y-axis still starts with 223).
Adding parameters such as ylim or ymax has not helped.

 

2. I am trying to convert it into a colour-coded image. I have
categories ranging from numbers 1 to 5 (as well as random unique larger
numbers referring to nonrecurrent values). With some help, I have managed to
assign my numeric values in my data to colours using this function:

 

RP2 <- as.matrix(RP)*1

TS <- Team1$Kat5

for (i in seq(1,dim(RP2)[1])) {

  for (j in seq(1,dim(RP2)[1])) {

    if (RP2[i,j] == 1 & TS[i] < 6) { # test if recurrence is present in RP
AND corresponding value in the time-series is < 6, in which case that
Recurrent is coded according to the value in the time series

      RP2[i,j] <- TS[i]

    } else if (RP2[i,j] == 1 & TS[i] < 6) { # if the above is not the case,
test if recurrence is present in RP AND corresponding value in the
time-series is > 5, in which case that recurrence is deleted from the RP

      RP2[i,j] <- 0

    }

  }

}

 

image.scale(RP2, zlim=c(1,5),col= c("yellow", "red", "blue", "green",
"orange")

 

My problem is that the image I receive from doing this (see attachment) is
scaled from 0 to 1 and I seem to be incapable of understanding why this is
and how to change it. Once again, I have tried using y and x lim as well as
max functions, but have not managed to attain any results.

 

I realize these are amateur questions but I have been struggling with this
for quite some time and would really appreciate any help I can get.

 

Thanks and best regards,

Lisa

 

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.