[R] Fractals with R
Atte Tenkanen
attenka at utu.fi
Wed Apr 18 13:31:12 CEST 2007
Now problems with plot-command...
I try to plot Julia set and the algorithm works, if the points are drawn during the loop. But if I want to save the values first to the matrix and then afterwards plot them at once, the picture is distorted. What's wrong with the plot-command? I think the PointsMatrix is ok?
-Atte
C=-0.7-0.4i # Complex parameter, connected to coordinate of the Mandelbrot set in a complex plane.
Limits=c(-2,2)
z=0+0i
MaxIter=60
cl=colours()
Step=seq(Limits[1],Limits[2],by=0.01)
PointsMatrix=array(0,dim=c(length(Step)*length(Step),3))
a1=0
for(x in Step)
{
for(y in Step)
{
z1=x+y*1i
n=0
z=z1
while(n<MaxIter & abs(z)<2)
{
z=z^2+C
n=n+1
}
if(abs(z)<2) colour=1
else colour=n*10
#points(z1, pch=".", col=cl[colour]) # This works!
# But this doesn't!
a1=a1+1
PointsMatrix[a1,]=c(x,y,colour)
}
}
#???
plot(PointsMatrix[,1], PointsMatrix[,2], xlim=Limits, ylim=Limits, col=cl[PointsMatrix[,3]], pch=".")
#----------------------------------------------------------------------------------------------------------------#
> Atte Tenkanen wrote:
> > Hi,
> >
> > That is of counter for web page. Do you get some pop-up windows?
> >
> >
> > Atte
>
> Hi Atte,
>
More information about the R-help
mailing list