Mercurial > hg > octave-lyh
comparison scripts/plot/loglog.m @ 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 | 7f127e079a7c |
children | 3b5449493bb8 |
comparison
equal
deleted
inserted
replaced
13102:801c5a6ad487 | 13103:2e2738837a24 |
---|---|
59 end_unwind_protect | 59 end_unwind_protect |
60 | 60 |
61 endfunction | 61 endfunction |
62 | 62 |
63 %!demo | 63 %!demo |
64 %! clf (); | |
64 %! t = 1:0.01:10; | 65 %! t = 1:0.01:10; |
65 %! x = sort ((t .* (1 + rand (size (t)))) .^ 2); | 66 %! x = sort ((t .* (1 + rand (size (t)))) .^ 2); |
66 %! y = ((t .* (1 + rand (size (t)))) .^ 2); | 67 %! y = ((t .* (1 + rand (size (t)))) .^ 2); |
67 %! loglog (x, y); | 68 %! loglog (x, y); |
68 | 69 |
69 ## Remove from test statistics. No real tests possible. | 70 %!demo |
70 %!assert (1) | 71 %! clf (); |
72 %! a = logspace (-5, 1, 10); | |
73 %! b =-logspace (-5, 1, 10); | |
74 %! | |
75 %! subplot (1, 2, 1) | |
76 %! loglog (a, b) | |
77 %! xlabel ('loglog (a, b)') | |
78 %! | |
79 %! subplot (1, 2, 2) | |
80 %! loglog (a, abs (b)) | |
81 %! set (gca, 'ydir', 'reverse') | |
82 %! xlabel ('loglog (a, abs (b))') | |
83 %! | |
84 %! fprintf ('the two plots should look the same except for the sign in y tick labels') | |
85 | |
86 | |
87 %!test | |
88 %! hf = figure (1232, "visible", "off"); | |
89 %! unwind_protect | |
90 %! a = logspace (-5, 1, 10); | |
91 %! b = logspace (-5, 1, 10); | |
92 %! loglog (a, b) | |
93 %! assert (get (gca, "yscale"), "log"); | |
94 %! assert (get (gca, "xscale"), "log"); | |
95 %! unwind_protect_cleanup | |
96 %! close (hf); | |
97 %! end_unwind_protect | |
98 | |
99 %!test | |
100 %! hf = figure (1232, "visible", "off"); | |
101 %! unwind_protect | |
102 %! a = logspace (-5, 1, 10); | |
103 %! b =-logspace (-5, 1, 10); | |
104 %! loglog (a, b) | |
105 %! axis tight | |
106 %! assert (all (get (gca, "ytick") < 0)); | |
107 %! unwind_protect_cleanup | |
108 %! close (hf); | |
109 %! end_unwind_protect | |
110 |