changeset 13103:2e2738837a24

Add tests and demos for log-scale plotting functions * semilogx.m, semilogy.m, loglog.m : Add new tests and demos.
author Carlo de Falco <kingcrimson@tiscali.it>
date Tue, 06 Sep 2011 15:38:32 +0200
parents 801c5a6ad487
children 3b5449493bb8
files scripts/plot/loglog.m scripts/plot/semilogx.m scripts/plot/semilogy.m
diffstat 3 files changed, 124 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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
+
--- 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
+
+
--- 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
+
+