Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
8d36cc80
Commit
8d36cc80
authored
Mar 08, 2013
by
Houtan Bastani
Browse files
reporting: table
parent
22caa866
Changes
6
Hide whitespace changes
Inline
Side-by-side
matlab/reports/@graph/createGraph.m
View file @
8d36cc80
...
...
@@ -49,10 +49,10 @@ end
%set(h, 'PaperPositionMode', 'auto');
%set(h, 'units', 'normalized', 'outerposition', [0 0 1 1]);
if
strcmpi
(
o
.
seriesto
plot
,
'all'
)
if
strcmpi
(
o
.
seriesto
use
,
'all'
)
data
=
o
.
data
.
data
;
else
data
=
o
.
data
{
o
.
seriesto
plot
{:}}
.
data
;
data
=
o
.
data
{
o
.
seriesto
use
{:}}
.
data
;
end
x
=
[
1
:
1
:
o
.
data
.
nobs
];
...
...
@@ -65,6 +65,13 @@ if ~isempty(o.shade)
x2
=
strmatch
(
lower
(
o
.
shade
{
2
}),
xlabels
,
'exact'
);
yrange
=
get
(
gca
,
'YLim'
);
if
isempty
(
x1
)
error
([
o
.
shade
{
1
}
' not in date range of provided data'
]);
end
if
isempty
(
x2
)
error
([
o
.
shade
{
2
}
' not in date range of provided data'
]);
end
% From ShadePlotForEmpahsis (Matlab Exchange)
% use patch bc area doesn't work with matlab2tikz
patch
([
repmat
(
x1
,
1
,
2
)
repmat
(
x2
,
1
,
2
)],
[
yrange
fliplr
(
yrange
)],
...
...
...
@@ -75,10 +82,10 @@ set(gca,'XTick', x);
set
(
gca
,
'XTickLabel'
,
xlabels
);
if
o
.
legend
if
strcmpi
(
o
.
seriesto
plot
,
'all'
)
if
strcmpi
(
o
.
seriesto
use
,
'all'
)
lh
=
legend
(
o
.
data
.
name
);
else
lh
=
legend
(
o
.
seriesto
plot
{:});
lh
=
legend
(
o
.
seriesto
use
{:});
end
set
(
lh
,
'orientation'
,
o
.
legend_orientation
);
set
(
lh
,
'Location'
,
o
.
legend_location
);
...
...
@@ -87,15 +94,15 @@ if o.legend
end
if
~
isempty
(
o
.
xlabel
)
xlabel
([
'$\textbf{\footnotesize '
o
.
xlabel
'}$'
],
'Interpreter'
,
'LaTex'
);
xlabel
([
'$\textbf{\footnotesize '
o
.
xlabel
'}$'
],
'Interpreter'
,
'LaTex'
);
end
if
~
isempty
(
o
.
ylabel
)
ylabel
([
'$\textbf{\footnotesize '
o
.
ylabel
'}$'
],
'Interpreter'
,
'LaTex'
);
ylabel
([
'$\textbf{\footnotesize '
o
.
ylabel
'}$'
],
'Interpreter'
,
'LaTex'
);
end
if
~
isempty
(
o
.
title
)
title
(
o
.
title
,
'
i
nterpreter'
,
'
none'
,
'FontSize'
,
20
);
title
(
o
.
title
,
'
I
nterpreter'
,
'
LaTex'
);
end
drawnow
;
...
...
matlab/reports/@graph/graph.m
View file @
8d36cc80
...
...
@@ -41,7 +41,7 @@ o.footnote = '';
o
.
figname
=
''
;
o
.
data
=
''
;
o
.
seriesto
plot
=
'all'
;
o
.
seriesto
use
=
'all'
;
o
.
shade
=
''
;
%{1959q1:1964q4}
o
.
grid
=
true
;
...
...
matlab/reports/@report/write.m
View file @
8d36cc80
...
...
@@ -41,7 +41,7 @@ if strcmpi(o.orientation, 'landscape')
fprintf
(
fid
,
',landscape'
);
end
fprintf
(
fid
,
']{geometry}\n'
);
fprintf
(
fid
,
'\\usepackage{
graphicx,
pdflscape, pgf, pgfplots}\n'
);
fprintf
(
fid
,
'\\usepackage{pdflscape, pgf, pgfplots
, booktabs
}\n'
);
fprintf
(
fid
,
[
'\\makeatletter\n'
...
'\\def\\blfootnote{\\gdef\\@thefnmark{}\\@footnotetext}\n'
...
'\\makeatother\n'
]);
...
...
@@ -53,6 +53,12 @@ if o.showdate
fprintf
(
fid
,
'\\renewcommand{\\footrulewidth}{0.5pt}\n'
);
fprintf
(
fid
,
'\\rfoot{\\scriptsize\\reportdate\\today\\ -- \\currenttime}\n'
);
end
% May not need these.....
fprintf
(
fid
,
'\\renewcommand{\\textfraction}{0.05}\n'
);
fprintf
(
fid
,
'\\renewcommand{\\topfraction}{0.8}\n'
);
fprintf
(
fid
,
'\\renewcommand{\\bottomfraction}{0.8}\n'
);
fprintf
(
fid
,
'\\usepackage[Export,PGF]{adjustbox}\n'
);
fprintf
(
fid
,
'\\begin{document}\n'
);
o
.
pages
.
write
(
fid
);
...
...
matlab/reports/@section/write.m
View file @
8d36cc80
...
...
@@ -31,29 +31,27 @@ function o = write(o, fid)
assert
(
fid
~=
-
1
);
fprintf
(
fid
,
'%% Section Object\n'
);
fprintf
(
fid
,
'\\begin{table}[%shtpb]\n'
,
o
.
align
);
fprintf
(
fid
,
'\\resizebox{\\textwidth}{!}{\n'
);
fprintf
(
fid
,
'\\begin{tabular}{'
);
%fprintf(fid, '\\begin{table}[%shtpb]%%\n', o.align);
fprintf
(
fid
,
' \\vspace{15px}\n'
);
fprintf
(
fid
,
'\\centering\n'
);
fprintf
(
fid
,
'\\noindent\\maxsizebox{\\textwidth}{!}{%%\n'
);
fprintf
(
fid
,
'\\begin{tabular}[t]{'
);
for
i
=
1
:
o
.
cols
fprintf
(
fid
,
'c'
);
end
fprintf
(
fid
,
'}\n'
);
% Calculate scaling factor
%sf = round(100/o.cols)/100-.01;
ne
=
numElements
(
o
);
for
i
=
1
:
ne
o
.
elements
(
i
)
.
write
(
fid
);
if
rem
(
i
,
o
.
cols
)
fprintf
(
fid
,
' & '
);
else
fprintf
(
fid
,
'\\\\\n'
);
fprintf
(
fid
,
'
\\\\\n'
);
end
end
fprintf
(
fid
,
'\\end{tabular}\n'
);
fprintf
(
fid
,
'}\n'
);
fprintf
(
fid
,
'\\end{table}\n'
);
fprintf
(
fid
,
'\\end{tabular}
%%
\n'
);
fprintf
(
fid
,
'}
%%
\n'
);
%
fprintf(fid, '\\end{table}
%%
\n');
fprintf
(
fid
,
'%% End Section Object\n\n'
);
end
\ No newline at end of file
matlab/reports/@table/table.m
View file @
8d36cc80
...
...
@@ -30,11 +30,19 @@ function o = table(varargin)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
o
=
struct
;
o
.
caption
=
''
;
o
.
title
=
''
;
o
.
footnote
=
''
;
o
.
config
=
''
;
o
.
hlines
=
false
;
o
.
vlines
=
false
;
o
.
data
=
''
;
o
.
datatitles
=
''
;
o
.
seriestouse
=
'all'
;
o
.
range
=
''
;
o
.
precision
=
1
;
if
nargin
==
1
assert
(
isa
(
varargin
{
1
},
'table'
),[
'With one arg to Table constructor, '
...
...
...
matlab/reports/@table/write.m
View file @
8d36cc80
...
...
@@ -3,10 +3,11 @@ function o = write(o, fid)
% Write a Table object
%
% INPUTS
% o - Table Object
% fid - int, file id
%
% OUTPUTS
% o -
this
% o -
Table Object
%
% SPECIAL REQUIREMENTS
% none
...
...
@@ -28,10 +29,104 @@ function o = write(o, fid)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
fid
>
0
);
assert
(
isnumeric
(
texIndent
));
assert
(
fid
~=
-
1
);
if
isempty
(
o
.
data
)
return
end
fprintf
(
fid
,
'%% Page Object\n'
);
%number of left-hand columns, 1 until we allow the user to group data,
% e.g.: GDP Europe
% GDP France
% GDP Germany
% this example would be two lh columns, with GDP Europe spanning both
nlhc
=
1
;
fprintf
(
fid
,
'%% End Page Object\n'
);
end
\ No newline at end of file
disp
(
'creating table.........'
);
fprintf
(
fid
,
'%% Table Object\n'
);
fprintf
(
fid
,
'\\begin{tabular}{l'
);
dates
=
o
.
data
.
time
;
ndates
=
dates
.
ndat
;
for
i
=
1
:
ndates
fprintf
(
fid
,
'r'
);
end
fprintf
(
fid
,
'}%%\n'
);
if
~
isempty
(
o
.
title
)
fprintf
(
fid
,
'\\multicolumn{%d}{c}{%s} \\\\\n'
,
ndates
+
nlhc
,
o
.
title
);
end
fprintf
(
fid
,
'\\toprule%%\n'
);
datedata
=
dates
.
time
;
years
=
unique
(
datedata
(:,
1
));
thdr
=
num2cell
(
years
,
size
(
years
,
1
));
lind
=
nlhc
;
switch
dates
.
freq
case
1
for
i
=
1
:
size
(
thdr
,
1
)
fprintf
(
fid
,
' & %d'
,
thdr
{
i
,
1
});
end
fprintf
(
fid
,
'\\\\%%\n'
);
for
i
=
1
:
size
(
thdr
,
1
)
rind
=
lind
+
1
;
fprintf
(
fid
,
'\\cmidrule(l{.5em}r{.5em}){%d-%d}'
,
lind
+
1
,
rind
);
lind
=
rind
;
end
case
4
thdr
{
1
,
2
}
=
datedata
(:,
2
)
'
;
if
size
(
thdr
,
1
)
>
1
for
i
=
2
:
size
(
thdr
,
1
)
split
=
find
(
thdr
{
i
-
1
,
2
}
==
4
,
1
,
'first'
);
if
isempty
(
split
)
error
(
'@table.write: Shouldn
''
t arrive here'
);
else
thdr
{
i
,
2
}
=
thdr
{
i
-
1
,
2
}(
split
+
1
:
end
);
thdr
{
i
-
1
,
2
}
=
thdr
{
i
-
1
,
2
}(
1
:
split
);
end
end
end
for
i
=
1
:
size
(
thdr
,
1
)
fprintf
(
fid
,
' & \\multicolumn{%d}{c}{%d}'
,
size
(
thdr
{
i
,
2
},
2
),
thdr
{
i
,
1
});
end
fprintf
(
fid
,
'\\\\%%\n'
);
for
i
=
1
:
size
(
thdr
,
1
)
rind
=
lind
+
size
(
thdr
{
i
,
2
},
2
);
fprintf
(
fid
,
'\\cmidrule(l{.5em}r{.5em}){%d-%d}'
,
lind
+
1
,
rind
);
lind
=
rind
;
end
for
i
=
1
:
size
(
thdr
,
1
)
quarters
=
thdr
{
i
,
2
};
for
j
=
1
:
size
(
quarters
,
2
)
fprintf
(
fid
,
' & Q%d'
,
quarters
(
j
));
end
end
fprintf
(
fid
,
'\\\\%%\n'
);
for
i
=
1
:
ndates
fprintf
(
fid
,
'\\cmidrule(l{.5em}r{.5em}){%d-%d}'
,
i
+
nlhc
,
i
+
nlhc
);
end
case
12
otherwise
error
(
'@table.write: invalid dynSeries Dates'
);
end
fprintf
(
fid
,
'%%\n'
);
vars
=
o
.
data
.
name
;
nvars
=
size
(
vars
);
data
=
o
.
data
.
data
;
assert
(
isint
(
o
.
precision
));
precision
=
10
^
o
.
precision
;
dataString
=
[
' & %.'
num2str
(
o
.
precision
)
'f'
];
for
i
=
1
:
nvars
fprintf
(
fid
,
'%% Table Row %d\n'
,
i
);
fprintf
(
fid
,
'%s'
,
vars
{
i
});
for
j
=
1
:
ndates
fprintf
(
fid
,
dataString
,
round
(
data
(
j
,
i
)
*
precision
)/
precision
);
end
fprintf
(
fid
,
' \\\\\n\n'
);
end
fprintf
(
fid
,
'\\bottomrule%%\n'
);
fprintf
(
fid
,
'\\end{tabular}%%\n'
);
fprintf
(
fid
,
'%% End Table Object\n'
);
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment