r – uso do Sys.sleep


I can't make a point-to-point graph, the R plot the graph later is in the Sys.sleep count, can someone help me?

  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)
  plot(flux, type = "o", col = "red4")

How can I increase the size of the chart?


Is a point-by-point graph an animation type graph? If so, the code below 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")

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

Scroll to Top