use of Sys.sleep

3

I can not make a peer-to-peer graph, the R% with% of the graph then stays in the count of plot , does anyone help me?

  n=1
  Cn=6.45
  x<-3
  t<- seq(1,20)
  for (i in 1:21) {
  flux  = round(Cn*sin(n*pi*x / 5)*exp(-(pi^2*n^2/25)*t), digits = 2)
  flux
  plot(flux, type = "o", col = "red4")
  Sys.sleep(.25)
  }

How can I increase the size of the chart?

    
asked by anonymous 07.11.2016 / 22:20

1 answer

1

Point to point graph would be a chart type an animation? If so, the following code will solve your problem:

# criacao as variaveis e calculo do flux

n  <- 1
Cn <- 6.45
x  <- 3
t  <- seq(1, 20)
flux  <- round(Cn*sin(n*pi*x / 5)*exp(-(pi^2*n^2/25)*t), digits=2)

# cria um grafico vazio com as dimensoes
plot(flux ~ t, type="n") 

for (i in 1:length(t)) {
  points(flux[i] ~ t[i], type="o", col="red4")
  Sys.sleep(.25)
}

The problem with the original code was to use the plot(flux, type = "o", col = "red4") command. It was run 21 times, always creating a complete chart with all 20 points. When using the points command, I can add the graph points one by one, without deleting the previous ones.

    
08.11.2016 / 01:03