From 16aebf892cd9202d9d298149ccd99d977ccdd47b Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Thu, 7 Mar 2013 15:45:53 +0100 Subject: [PATCH] reporting (WIP) --- matlab/reporting/@graph/createGraph.m | 13 ++++++++++--- matlab/reporting/@graph/graph.m | 2 ++ matlab/reporting/@page/page.m | 1 + matlab/reporting/@page/write.m | 9 ++++++++- matlab/reporting/@report/report.m | 3 ++- matlab/reporting/@report/write.m | 16 ++++++++++++---- 6 files changed, 35 insertions(+), 9 deletions(-) diff --git a/matlab/reporting/@graph/createGraph.m b/matlab/reporting/@graph/createGraph.m index b696a305e2..4e46ea97f8 100644 --- a/matlab/reporting/@graph/createGraph.m +++ b/matlab/reporting/@graph/createGraph.m @@ -3,10 +3,10 @@ function o = createGraph(o) % Create the graph % % INPUTS -% none +% o - Graph Object % % OUTPUTS -% none +% o - Graph Object % % SPECIAL REQUIREMENTS % none @@ -37,9 +37,14 @@ end %o = readConfig(o); +disp('creating plot..........'); h = figure('visible','off'); hold on; box on; +if o.grid + grid on; + set(gca, 'GridLineStyle', '--'); +end %set(0, 'CurrentFigure',h); %set(h, 'PaperPositionMode', 'auto'); %set(h, 'units', 'normalized', 'outerposition', [0 0 1 1]); @@ -90,16 +95,18 @@ if ~isempty(o.ylabel) end if ~isempty(o.title) - title(['$\textbf{\large ' o.title '}$'],'Interpreter','LaTex'); + title( o.title , 'interpreter', 'none', 'FontSize', 20); end drawnow; o.figname = ['figure-' num2str(cputime) '.tex']; +disp(' converting to tex....'); matlab2tikz('filename', o.figname, ... 'showInfo', false, ... 'showWarnings', false, ... 'checkForUpdates', false); +grid off; box off; hold off; close(h); diff --git a/matlab/reporting/@graph/graph.m b/matlab/reporting/@graph/graph.m index 2d7d87c2ce..ae98ab810f 100644 --- a/matlab/reporting/@graph/graph.m +++ b/matlab/reporting/@graph/graph.m @@ -44,6 +44,8 @@ o.data = ''; o.seriestoplot = 'all'; o.shade = ''; %{1959q1:1964q4} +o.grid = true; + o.legend = false; o.legend_location = 'SouthEast'; o.legend_orientation = 'horizontal'; diff --git a/matlab/reporting/@page/page.m b/matlab/reporting/@page/page.m index f7f1c2c453..d0dd38caef 100644 --- a/matlab/reporting/@page/page.m +++ b/matlab/reporting/@page/page.m @@ -33,6 +33,7 @@ o = struct; o.paper = ''; o.title = ''; o.orientation = ''; +o.footnote = ''; o.sections = sections(); if nargin == 1 diff --git a/matlab/reporting/@page/write.m b/matlab/reporting/@page/write.m index 4944b3d510..9afb4ad30b 100644 --- a/matlab/reporting/@page/write.m +++ b/matlab/reporting/@page/write.m @@ -32,8 +32,15 @@ assert(fid ~= -1); fprintf(fid, '\n%% Page Object\n'); if ~isempty(o.title) - fprintf(fid, '\\centerline{{\\Large %s}}\n', o.title); + fprintf(fid, '\\centerline{\\large\\textbf{%s}}\n', o.title); end + +if ~isempty(o.footnote) + for i=1:length(o.footnote) + fprintf(fid, '\\blfootnote{\\tiny %d. %s}', i, o.footnote{i}); + end +end + if strcmpi(o.orientation, 'landscape') fprintf(fid, '\\begin{landscape}\n') end diff --git a/matlab/reporting/@report/report.m b/matlab/reporting/@report/report.m index a045c5c880..0fd4de327b 100644 --- a/matlab/reporting/@report/report.m +++ b/matlab/reporting/@report/report.m @@ -34,10 +34,11 @@ o = struct; o.title = ''; o.orientation = 'portrait'; o.paper = 'a4'; -o.margin = '2cm'; +o.margin = '2.5cm'; o.pages = pages(); o.filename = 'report.tex'; o.config = ''; +o.showdate = true; if nargin == 1 assert(isa(varargin{1}, 'report'),['With one arg to Report constructor, ' ... diff --git a/matlab/reporting/@report/write.m b/matlab/reporting/@report/write.m index 6b686c662e..0caab5df55 100644 --- a/matlab/reporting/@report/write.m +++ b/matlab/reporting/@report/write.m @@ -41,10 +41,18 @@ if strcmpi(o.orientation, 'landscape') fprintf(fid, ',landscape'); end fprintf(fid, ']{geometry}\n'); -fprintf(fid, '\\usepackage{graphicx}\n'); -fprintf(fid, '\\usepackage{pdflscape}\n'); -fprintf(fid, '\\usepackage{pgf}\n'); -fprintf(fid, '\\usepackage{pgfplots}\n'); +fprintf(fid, '\\usepackage{graphicx, pdflscape, pgf, pgfplots}\n'); +fprintf(fid, ['\\makeatletter\n' ... + '\\def\\blfootnote{\\gdef\\@thefnmark{}\\@footnotetext}\n' ... + '\\makeatother\n']); +if o.showdate + fprintf(fid, '\\usepackage{fancyhdr, datetime}\n'); + fprintf(fid, '\\newdateformat{reportdate}{\\THEDAY\\ \\shortmonthname\\ \\THEYEAR}\n'); + fprintf(fid, '\\pagestyle{fancy}\n'); + fprintf(fid, '\\renewcommand{\\headrulewidth}{0pt}\n'); + fprintf(fid, '\\renewcommand{\\footrulewidth}{0.5pt}\n'); + fprintf(fid, '\\rfoot{\\scriptsize\\reportdate\\today\\ -- \\currenttime}\n'); +end fprintf(fid, '\\begin{document}\n'); o.pages.write(fid); -- GitLab