Mercurial > octave-libgccjit
annotate scripts/testfun/private/compare_plot_demos.m @ 18925:87324260043d
Improve plot comparison scripts.
* compare_plot_demos.m: pass toolkits{} to html_compare_plot_demos.
Give instructions for toolkit matlab. Fix whitespace issue.
* dump_demos.m: fix typo in default dir. Consistently use dump_plot_demos.m
for main worker script. Create diary and error messages for inclusion in
html page. Set random seed for better comparison.
* html_plot_demos_template.html: Allow variable toolkits (removed hard-coded
gnuplot, matlab, fltk sequence). Fix some whitespace issues.
* html_compare_plot_demos.m: Rewrite docstring. The instructions are no longer
needed because compare_plot_demos handles them. Add "toolkits" and
column_width param. Dynamically add toolkits in html, add diary.log link.
author | Andreas Weber <andy.weber.aw@gmail.com> |
---|---|
date | Tue, 15 Jul 2014 22:18:35 +0200 |
parents | f9cf5ae6b8a2 |
children |
rev | line source |
---|---|
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
1 ## Copyright (C) 2012 Ben Abbott <bpabbott@mac.com> |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
2 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
4 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
8 ## your option) any later version. |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
9 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
13 ## General Public License for more details. |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
14 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
18 |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
20 ## @deftypefn {Function File} {} compare_plot_demos () |
18895 | 21 ## @deftypefnx {Function File} {} compare_plot_demos ("toolkits", @{@var{toolkit1}, @var{toolkit2}, @dots{}@}) |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
22 ## |
18895 | 23 ## Uses @code{dump_demos} and @code{html_compare_plot_demos} to produce an |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18897
diff
changeset
|
24 ## html comparison of the plot demos for each of Octave's graphics toolkits. |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
25 ## |
18895 | 26 ## An m-file named @file{dump_plots.m} will be created in the current working |
27 ## directory. This function will be used to render and save the plot demo | |
28 ## images. | |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
29 ## |
18895 | 30 ## If they do not already exist, directories for each available graphics |
31 ## toolkit are created. Each toolkit's directory will be populated with images | |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
32 ## of each plot demo in the png format. |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
33 ## |
18895 | 34 ## Finally, an html document named @file{compare_plot_demos.html} is produced. |
35 ## This page places each toolkit's images side by side for a convenient | |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
36 ## comparison of the results. |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
37 ## |
18895 | 38 ## If the property @qcode{"toolkits"} is given then compare only the listed |
39 ## toolkits in the cell string. The list may also include the toolkit | |
40 ## @qcode{"matlab"}. | |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
41 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
42 ## @end deftypefn |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
43 |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
44 ## Author: Ben Abbott <bpabbott@mac.com> |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
45 |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
46 function compare_plot_demos (varargin) |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
47 |
18895 | 48 arg.toolkits = available_graphics_toolkits (); |
18897
f9cf5ae6b8a2
Add image directory to plot comparison scripts.
Rik <rik@octave.org>
parents:
18895
diff
changeset
|
49 arg.directories = {"plot/appearance", "plot/draw", "plot/util", "image"}; |
18895 | 50 arg.fmt = "png"; |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18897
diff
changeset
|
51 arg.fcn_file = "dump_plot_demos.m"; |
18895 | 52 arg.replace_images = false; |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
53 |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
54 for n = 1:2:numel(varargin) |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
55 if (! ischar (varargin{n})) |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
56 print_usage (); |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
57 else |
18895 | 58 arg.(varargin{n}) = varargin{n+1}; |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
59 endif |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
60 endfor |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
61 |
18895 | 62 if (ischar (arg.toolkits)) |
63 arg.toolkits = {arg.toolkits}; | |
64 elseif (! iscellstr (arg.toolkits)) | |
65 error ('compare_plot_demos: Invalid value for "toolkits"') | |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
66 endif |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
67 |
18895 | 68 if (ischar (arg.directories)) |
69 arg.directories = {arg.directories}; | |
70 elseif (! iscellstr (arg.directories)) | |
71 error ('compare_plot_demos: Invalid value for "directory"') | |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
72 endif |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
73 |
18895 | 74 if (! ischar (arg.fmt)) |
75 error ('compare_plot_demos: Invalid value for "fmt"') | |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
76 endif |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
77 |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18897
diff
changeset
|
78 ## Generate arg.fcn_file for rendering/saving the plot demo images |
18895 | 79 dump_demos (arg.directories, arg.fcn_file, arg.fmt); |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
80 |
18895 | 81 [~, fcn_name] = fileparts (arg.fcn_file); |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
82 |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
83 ## Generate the plot demo images for each toolkit |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
84 cwd = pwd (); |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
85 unwind_protect |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
86 addpath (pwd); |
18895 | 87 for n = 1:numel (arg.toolkits) |
88 if (! isdir (fullfile (cwd, arg.toolkits{n}))) | |
89 mkdir (arg.toolkits{n}); | |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
90 endif |
18895 | 91 cd (arg.toolkits{n}); |
92 if (arg.replace_images && ! isempty (dir (["*." arg.fmt]))) | |
93 delete (["*." arg.fmt]); | |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
94 endif |
18895 | 95 if (! strcmp (arg.toolkits{n}, "matlab")) |
96 close all; | |
97 graphics_toolkit (arg.toolkits{n}); | |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
98 try |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
99 eval (fcn_name); |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
100 catch |
18895 | 101 printf ("Error running plot demos for ""%s"" toolkit\n", arg.toolkits{n}); |
102 disp (lasterror); | |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
103 end_try_catch |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
104 endif |
18895 | 105 cd (cwd); |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
106 endfor |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
107 unwind_protect_cleanup |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
108 rmpath (cwd); |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
109 end_unwind_protect |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18897
diff
changeset
|
110 if (! strcmp (arg.toolkits, "matlab")) |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18897
diff
changeset
|
111 ## Generate the html comparison of the images |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18897
diff
changeset
|
112 html_compare_plot_demos (arg.toolkits); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18897
diff
changeset
|
113 else |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18897
diff
changeset
|
114 ## We need to run matlab manually before the html page can be created |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18897
diff
changeset
|
115 printf ('\nNow run %s in Matlab.\nAfter this run html_compare_plot_demos,\n', arg.fcn_file); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18897
diff
changeset
|
116 printf ('for example html_compare_plot_demos ({"fltk", "gnuplot", "matlab"}), to create the html page.\n'); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18897
diff
changeset
|
117 endif |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
118 endfunction |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
119 |