Skip to content

Commit b5fddba

Browse files
committed
added annotate plots
1 parent b7c62cf commit b5fddba

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

src/plotting.jl

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,14 +1302,17 @@ function plot_irf!(𝓂::ℳ;
13021302

13031303
param_nms = diffdict[:parameters]|>keys|>collect|>sort
13041304

1305-
plot_vector = Pair{String,Any}[]
1305+
annotate_ss = Pair{String,Any}[]
1306+
1307+
annotate_params = Pair{String,Any}[]
1308+
13061309
for param in param_nms
1307-
push!(plot_vector, String(param) => diffdict[:parameters][param])
1310+
push!(annotate_params, String(param) => diffdict[:parameters][param])
13081311
end
13091312

1310-
pushfirst!(plot_vector, "Plot index" => 1:length(diffdict[:parameters][param_nms[1]]))
1313+
pushfirst!(annotate_params, "Plot index" => 1:length(diffdict[:parameters][param_nms[1]]))
13111314

1312-
annotate_plot = plot_df(plot_vector)
1315+
annotate_params_plot = plot_df(annotate_params)
13131316

13141317
return_plots = []
13151318

@@ -1333,8 +1336,16 @@ function plot_irf!(𝓂::ℳ;
13331336
variable_name = replace_indices_in_symbol(𝓂.timings.var[var_idx[i]])
13341337

13351338
# push!(pp, plot_irf_subplot(Y[i,:,shock], SS, variable_name, can_dual_axis))
1336-
1337-
push!(pp, plot_irf_subplot([k[:plot_data][i,:,shock] for k in irf_active_plot_container], [k[:reference_steady_state][var_idx[i]] for k in irf_active_plot_container], variable_name, can_dual_axis))
1339+
SSs = [k[:reference_steady_state][var_idx[i]] for k in irf_active_plot_container]
1340+
1341+
if maximum(SSs) - minimum(SSs) > 1e-10
1342+
push!(annotate_ss, String(variable_name) => SSs)
1343+
end
1344+
1345+
push!(pp, plot_irf_subplot( [k[:plot_data][i,:,shock] for k in irf_active_plot_container],
1346+
SSs,
1347+
variable_name,
1348+
can_dual_axis))
13381349

13391350
if !(plot_count % plots_per_page == 0)
13401351
plot_count += 1
@@ -1357,8 +1368,12 @@ function plot_irf!(𝓂::ℳ;
13571368

13581369
ppp = StatsPlots.plot(pp...; attributes...)
13591370

1371+
annotate_ss_plot = plot_df(annotate_ss)
1372+
1373+
ppp2 = StatsPlots.plot(annotate_params_plot, annotate_ss_plot; attributes...)
1374+
13601375
p = StatsPlots.plot(ppp,
1361-
annotate_plot,
1376+
ppp2,
13621377
layout = StatsPlots.grid(2, 1, heights = [0.8, 0.2]),
13631378
plot_title = "Model: "*𝓂.model_name*" " * shock_dir * shock_string *" ("*string(pane)*"/"*string(Int(ceil(n_subplots/plots_per_page)))*")";
13641379
attributes_redux...)
@@ -1374,12 +1389,14 @@ function plot_irf!(𝓂::ℳ;
13741389
end
13751390

13761391
pane += 1
1392+
1393+
annotate_ss = Pair{String,Any}[]
13771394

13781395
pp = []
13791396
end
13801397
end
13811398
end
1382-
1399+
13831400
if length(pp) > 0
13841401
if shocks == :simulate
13851402
shock_string = ": simulate all"
@@ -1397,8 +1414,12 @@ function plot_irf!(𝓂::ℳ;
13971414

13981415
ppp = StatsPlots.plot(pp...; attributes...)
13991416

1417+
annotate_ss_plot = plot_df(annotate_ss)
1418+
1419+
ppp2 = StatsPlots.plot(annotate_params_plot, annotate_ss_plot; attributes...)
1420+
14001421
p = StatsPlots.plot(ppp,
1401-
annotate_plot,
1422+
ppp2,
14021423
layout = StatsPlots.grid(2, 1, heights = [0.8, 0.2]),
14031424
plot_title = "Model: "*𝓂.model_name*" " * shock_dir * shock_string *" ("*string(pane)*"/"*string(Int(ceil(n_subplots/plots_per_page)))*")";
14041425
attributes_redux...)

0 commit comments

Comments
 (0)