comparison 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
comparison
equal deleted inserted replaced
18924:9a5e03801d23 18925:87324260043d
19 ## -*- texinfo -*- 19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} compare_plot_demos () 20 ## @deftypefn {Function File} {} compare_plot_demos ()
21 ## @deftypefnx {Function File} {} compare_plot_demos ("toolkits", @{@var{toolkit1}, @var{toolkit2}, @dots{}@}) 21 ## @deftypefnx {Function File} {} compare_plot_demos ("toolkits", @{@var{toolkit1}, @var{toolkit2}, @dots{}@})
22 ## 22 ##
23 ## Uses @code{dump_demos} and @code{html_compare_plot_demos} to produce an 23 ## Uses @code{dump_demos} and @code{html_compare_plot_demos} to produce an
24 ## html comparison of the plot demos for each of Octave's graphics toolkits. 24 ## html comparison of the plot demos for each of Octave's graphics toolkits.
25 ## 25 ##
26 ## An m-file named @file{dump_plots.m} will be created in the current working 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 27 ## directory. This function will be used to render and save the plot demo
28 ## images. 28 ## images.
29 ## 29 ##
46 function compare_plot_demos (varargin) 46 function compare_plot_demos (varargin)
47 47
48 arg.toolkits = available_graphics_toolkits (); 48 arg.toolkits = available_graphics_toolkits ();
49 arg.directories = {"plot/appearance", "plot/draw", "plot/util", "image"}; 49 arg.directories = {"plot/appearance", "plot/draw", "plot/util", "image"};
50 arg.fmt = "png"; 50 arg.fmt = "png";
51 arg.fcn_file = ""; 51 arg.fcn_file = "dump_plot_demos.m";
52 arg.replace_images = false; 52 arg.replace_images = false;
53 53
54 for n = 1:2:numel(varargin) 54 for n = 1:2:numel(varargin)
55 if (! ischar (varargin{n})) 55 if (! ischar (varargin{n}))
56 print_usage (); 56 print_usage ();
73 73
74 if (! ischar (arg.fmt)) 74 if (! ischar (arg.fmt))
75 error ('compare_plot_demos: Invalid value for "fmt"') 75 error ('compare_plot_demos: Invalid value for "fmt"')
76 endif 76 endif
77 77
78 if (isempty (arg.fcn_file)) 78 ## Generate arg.fcn_file for rendering/saving the plot demo images
79 arg.fcn_file = "dump_plot_demos.m";
80 endif
81
82 ## Generate "dump_plot_demos.m" for rendering/saving the plot demo images
83 dump_demos (arg.directories, arg.fcn_file, arg.fmt); 79 dump_demos (arg.directories, arg.fcn_file, arg.fmt);
84 80
85 [~, fcn_name] = fileparts (arg.fcn_file); 81 [~, fcn_name] = fileparts (arg.fcn_file);
86 82
87 ## Generate the plot demo images for each toolkit 83 ## Generate the plot demo images for each toolkit
109 cd (cwd); 105 cd (cwd);
110 endfor 106 endfor
111 unwind_protect_cleanup 107 unwind_protect_cleanup
112 rmpath (cwd); 108 rmpath (cwd);
113 end_unwind_protect 109 end_unwind_protect
114 110 if (! strcmp (arg.toolkits, "matlab"))
115 ## Generate the html comparison of the images 111 ## Generate the html comparison of the images
116 ## TODO: pass the toolkits{} to allow number of columns to be formatted 112 html_compare_plot_demos (arg.toolkits);
117 html_compare_plot_demos ("output", "compare_plot_demos.html") 113 else
118 114 ## We need to run matlab manually before the html page can be created
115 printf ('\nNow run %s in Matlab.\nAfter this run html_compare_plot_demos,\n', arg.fcn_file);
116 printf ('for example html_compare_plot_demos ({"fltk", "gnuplot", "matlab"}), to create the html page.\n');
117 endif
119 endfunction 118 endfunction
120 119