# HG changeset patch # User Carlo de Falco # Date 1315316312 -7200 # Node ID 2e2738837a240d96675afb098a2191eaef73b4e8 # Parent 801c5a6ad4878f203ed715486f3a3bea2c8b2c44 Add tests and demos for log-scale plotting functions * semilogx.m, semilogy.m, loglog.m : Add new tests and demos. diff -r 801c5a6ad487 -r 2e2738837a24 scripts/plot/loglog.m --- a/scripts/plot/loglog.m Mon Sep 05 10:35:09 2011 -0500 +++ b/scripts/plot/loglog.m Tue Sep 06 15:38:32 2011 +0200 @@ -61,10 +61,50 @@ endfunction %!demo +%! clf (); %! t = 1:0.01:10; %! x = sort ((t .* (1 + rand (size (t)))) .^ 2); %! y = ((t .* (1 + rand (size (t)))) .^ 2); %! loglog (x, y); -## Remove from test statistics. No real tests possible. -%!assert (1) +%!demo +%! clf (); +%! a = logspace (-5, 1, 10); +%! b =-logspace (-5, 1, 10); +%! +%! subplot (1, 2, 1) +%! loglog (a, b) +%! xlabel ('loglog (a, b)') +%! +%! subplot (1, 2, 2) +%! loglog (a, abs (b)) +%! set (gca, 'ydir', 'reverse') +%! xlabel ('loglog (a, abs (b))') +%! +%! fprintf ('the two plots should look the same except for the sign in y tick labels') + + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! a = logspace (-5, 1, 10); +%! b = logspace (-5, 1, 10); +%! loglog (a, b) +%! assert (get (gca, "yscale"), "log"); +%! assert (get (gca, "xscale"), "log"); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! a = logspace (-5, 1, 10); +%! b =-logspace (-5, 1, 10); +%! loglog (a, b) +%! axis tight +%! assert (all (get (gca, "ytick") < 0)); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + diff -r 801c5a6ad487 -r 2e2738837a24 scripts/plot/semilogx.m --- a/scripts/plot/semilogx.m Mon Sep 05 10:35:09 2011 -0500 +++ b/scripts/plot/semilogx.m Tue Sep 06 15:38:32 2011 +0200 @@ -65,5 +65,44 @@ %! y = (x .* (1 + rand (size (x)))) .^ 2; %! semilogx (y, x); -## Remove from test statistics. No real tests possible. -%!assert (1) +%!demo +%! clf (); +%! a = logspace (-5, 1, 10); +%! b =-logspace (-5, 1, 10); +%! +%! subplot (1, 2, 1) +%! semilogx (b, a) +%! xlabel ('semilogx (a, b)') +%! +%! subplot (1, 2, 2) +%! semilogx (abs (b), a) +%! set (gca, 'ydir', 'reverse') +%! xlabel ('semilogx (a, abs (b))') +%! +%! fprintf ('the two plots should look the same except for the sign in x tick labels') + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! a = logspace (-5, 1, 10); +%! b = logspace (-5, 1, 10); +%! semilogx (a, b) +%! assert (get (gca, "xscale"), "log"); +%! assert (get (gca, "yscale"), "linear"); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! a = logspace (-5, 1, 10); +%! b =-logspace (-5, 1, 10); +%! semilogx (a, b) +%! axis tight +%! assert (all (get (gca, "ytick") < 0)); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + + diff -r 801c5a6ad487 -r 2e2738837a24 scripts/plot/semilogy.m --- a/scripts/plot/semilogy.m Mon Sep 05 10:35:09 2011 -0500 +++ b/scripts/plot/semilogy.m Tue Sep 06 15:38:32 2011 +0200 @@ -66,5 +66,44 @@ %! y = (x .* (1 + rand (size (x)))) .^ 2; %! semilogy (x, y); -## Remove from test statistics. No real tests possible. -%!assert (1) +%!demo +%! clf (); +%! a = logspace (-5, 1, 10); +%! b =-logspace (-5, 1, 10); +%! +%! subplot (1, 2, 1) +%! semilogy (a, b) +%! xlabel ('semilogy (a, b)') +%! +%! subplot (1, 2, 2) +%! semilogy (a, abs (b)) +%! set (gca, 'ydir', 'reverse') +%! xlabel ('semilogy (a, abs (b))') +%! +%! fprintf ('the two plots should look the same except for the sign in y tick labels') + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! a = logspace (-5, 1, 10); +%! b = logspace (-5, 1, 10); +%! semilogy (a, b) +%! assert (get (gca, "yscale"), "log"); +%! assert (get (gca, "xscale"), "linear"); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! a = logspace (-5, 1, 10); +%! b =-logspace (-5, 1, 10); +%! semilogy (a, b) +%! axis tight +%! assert (all (get (gca, "ytick") < 0)); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +