[R] why I could not reproduce the Mandelbrot plot demonstrated on R wiki

xin wei xinwei at stat.psu.edu
Fri Sep 24 22:41:16 CEST 2010


I am trying to reproduce the nice looking of Mandelbrot demonstrated by R
wiki page by the following code:

library(caTools)        # external package providing write.gif function
jet.colors = colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan",
"#7FFF7F", 
                                "yellow", "#FF7F00", "red", "#7F0000")) 
m = 600                 # define size
C = complex( real=rep(seq(-1.8,0.6, length.out=m), each=m ), 
             imag=rep(seq(-1.2,1.2, length.out=m), m ) ) 
C = matrix(C,m,m)       # reshape as square matrix of complex numbers
Z = 0                   # initialize Z to zero
X = array(0, c(m,m,20)) # initialize output 3D array
for (k in 1:20) {       # loop with 20 iterations
  Z = Z^2+C             # the central difference equation  
  X[,,k] = exp(-abs(Z)) # capture results
} 
write.gif(X, "Mandelbrot.gif", col=jet.colors, delay=100)

however, the gif file created by this looks much worse than what is shown on
R wiki page, see the comparison as follows (left one is what i created)

http://r.789695.n4.nabble.com/file/n2591429/Picture1.png 
-- 
View this message in context: http://r.789695.n4.nabble.com/why-I-could-not-reproduce-the-Mandelbrot-plot-demonstrated-on-R-wiki-tp2591429p2591429.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list