help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Subplot draws ylabels out of range


From: Tobal
Subject: Subplot draws ylabels out of range
Date: Wed, 12 Jun 2013 11:31:30 -0700 (PDT)

Hi, I'm drawing plots with subplots but ylabels are drawn in the incorrect
place. It always plots ylabels inside the other subplot. The code

function [] = pfijo(g,f,a,b,a1,b1,x1,tol,maxiter)
        filename = 'puntofijo.txt';
        fid = fopen(filename,'w');
        fprintf(fid,'k\t\tx (k)\t\t\t\t\t\t\tError\n');

        t = a:0.01:b;
        t1 = a1:0.01:b1;
        fx = inline(f);
        gx = inline(g);
        func = fx(t);
        func1 = fx(t1);
        iter = 1;
        x = x1;
        incr = tol+1;
        errores = incr;
        imagenes = [ ];
        while incr > tol && iter <= maxiter
                x(iter+1) = feval(gx,x(iter));
                incr = abs(x(iter+1)-x(iter));
                errores =[errores,incr];
                iter++;
        end

        iter2 = 1:1:iter;
        fc1 = feval(fx,x);
        imagenes = [imagenes,fc1];
        if incr > tol
                sol = [ ];
                disp('Insuficientes iteraciones');
        else
                sol = x(end);
                for k=1:iter
                        
fprintf(fid,'%.0f\t\t%.15f\t\t%.15f\n',iter2(k),x(k),errores(k));
                end
                fprintf (fid,'\nLa soluciĆ³n es %.15f.\nSe ha alcanzado en %d
iteraciones.\nCon un error de %e',sol,iter,errores(end));
                fclose(fid);
                printf ('La solucion es %.15f, y se ha alcanzado en %d 
iteraciones.\n',
             sol, iter);
        end
        clf();
        subplot(1,3,1);
        plot(t1,func1)
        set (gca, 'xaxislocation', 'zero');
        set (gca, 'yaxislocation', 'zero');
        set(gca, 'box', 'off');
        grid;
        title('La Funcion');
        legend({f},'location', 'southoutside');
        legend boxon;
        xlabel('y');
        ylabel('x');
        set (get (gca, 'ylabel'), 'rotation', 360);
        subplot(1,3,2);
        plot(t,func,x,imagenes,'*r')
        set (gca, 'xaxislocation', 'zero');
        set (gca, 'yaxislocation', 'left');
        set(gca, 'box', 'off');
        grid;
        title('Metodo Punto Fijo');
        legend({f,'Aproximaciones'},'location','southoutside');
        legend boxon;
        xlabel('y');
        ylabel('x');
        %drawLabels (-5, 0, 'label');
        set (get (gca, 'ylabel'), 'rotation', 360);
        subplot(1,3,3);
        plot(iter2,errores)
        set (gca, 'xaxislocation', 'bottom');
        set (gca, 'yaxislocation', 'left');
        set(gca, 'box', 'on');
        grid;
        title('Tendencia de errores en Regula Falsi');
        legend('Errores','location','southoutside');
        legend boxon;
        xlabel('Numero Iteraciones');
        ylabel('Errores');
        set (get (gca, 'ylabel'), 'rotation', 360);
end

Executing this

pfijo('cos(x)','x-cos(x)',0,1,-pi,pi,1,0.001,100)

I see this image:

octave.png <http://octave.1599824.n4.nabble.com/file/n4654111/octave.png>  



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Subplot-draws-ylabels-out-of-range-tp4654111.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]