function ShowSphericalHarmonicFunction(N)
seg=64;
theta=linspace(0,pi,seg);
phi=linspace(0,2*pi,seg);
Theta=theta'*ones(1,seg);
Phi=ones(seg,1)*phi;
x=sin(Theta).*cos(Phi);
y=sin(Theta).*sin(Phi);
z=cos(Theta);
for mode=1:3;
    figure('color',[1,1,1]);ax=1;
    for n=0:N;
        L=legendre(n,cos(theta));
        for m=-n:n;
            LL=L(abs(m)+1,:);
            c=sqrt((2*n+1)*factorial(n-m)/(factorial(n+m))*4*pi)*LL'*exp(1i*m*phi);
            subplot(N+1,N+1,ax);
            ax=ax+1;
            if mode==1;
                r=abs(c);
            elseif mode==2;
                r=(real(c)+imag(c)).^2;
            else
                r=abs(2+c/max(abs(c(:))));%tentative
            end;
            h=surf(r.*x,r.*y,r.*z,abs(c));
            set(h,'EdgeColor','none','FaceColor','interp');
            camzoom(1);
            daspect([1,1,1]);axis tight;axis off;
            rotate3d on;
            title(sprintf('Y%d,%d',n,m));
        end;
    end;    
end;