Skip to content

Commit b7c62cf

Browse files
committed
first working prototype of plot annotation
1 parent ef70109 commit b7c62cf

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

src/plotting.jl

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,19 @@ function plot_irf!(𝓂::ℳ;
12981298

12991299
push!(irf_active_plot_container, args_and_kwargs)
13001300

1301+
diffdict = compare_args_and_kwargs(irf_active_plot_container)
1302+
1303+
param_nms = diffdict[:parameters]|>keys|>collect|>sort
1304+
1305+
plot_vector = Pair{String,Any}[]
1306+
for param in param_nms
1307+
push!(plot_vector, String(param) => diffdict[:parameters][param])
1308+
end
1309+
1310+
pushfirst!(plot_vector, "Plot index" => 1:length(diffdict[:parameters][param_nms[1]]))
1311+
1312+
annotate_plot = plot_df(plot_vector)
1313+
13011314
return_plots = []
13021315

13031316
for shock in 1:length(shock_idx)
@@ -1342,7 +1355,13 @@ function plot_irf!(𝓂::ℳ;
13421355
shock_name = "shock_matrix"
13431356
end
13441357

1345-
p = StatsPlots.plot(pp..., plot_title = "Model: "*𝓂.model_name*" " * shock_dir * shock_string *" ("*string(pane)*"/"*string(Int(ceil(n_subplots/plots_per_page)))*")"; attributes_redux...)
1358+
ppp = StatsPlots.plot(pp...; attributes...)
1359+
1360+
p = StatsPlots.plot(ppp,
1361+
annotate_plot,
1362+
layout = StatsPlots.grid(2, 1, heights = [0.8, 0.2]),
1363+
plot_title = "Model: "*𝓂.model_name*" " * shock_dir * shock_string *" ("*string(pane)*"/"*string(Int(ceil(n_subplots/plots_per_page)))*")";
1364+
attributes_redux...)
13461365

13471366
push!(return_plots,p)
13481367

@@ -1376,7 +1395,13 @@ function plot_irf!(𝓂::ℳ;
13761395
shock_name = "shock_matrix"
13771396
end
13781397

1379-
p = StatsPlots.plot(pp..., plot_title = "Model: "*𝓂.model_name*" " * shock_dir * shock_string * " (" * string(pane) * "/" * string(Int(ceil(n_subplots/plots_per_page)))*")"; attributes_redux...)
1398+
ppp = StatsPlots.plot(pp...; attributes...)
1399+
1400+
p = StatsPlots.plot(ppp,
1401+
annotate_plot,
1402+
layout = StatsPlots.grid(2, 1, heights = [0.8, 0.2]),
1403+
plot_title = "Model: "*𝓂.model_name*" " * shock_dir * shock_string *" ("*string(pane)*"/"*string(Int(ceil(n_subplots/plots_per_page)))*")";
1404+
attributes_redux...)
13801405

13811406
push!(return_plots,p)
13821407

@@ -1417,9 +1442,9 @@ function plot_df(plot_vector::Vector{Pair{String,Any}})
14171442

14181443
# overlay the header and numeric values
14191444
for j in 1:ncols
1420-
annotate!(df_plot, j, 1, text(plot_vector[j].first, :center, 8)) # Header
1445+
StatsPlots.annotate!(df_plot, j, 1, StatsPlots.text(plot_vector[j].first, :center, 8)) # Header
14211446
for i in 1:nrows
1422-
annotate!(df_plot, j, i + 1, text(string(plot_vector[j].second[i]), :center, 8))
1447+
StatsPlots.annotate!(df_plot, j, i + 1, StatsPlots.text(string(plot_vector[j].second[i]), :center, 8))
14231448
end
14241449
end
14251450

@@ -1895,15 +1920,15 @@ function plot_solution(𝓂::ℳ,
18951920
end
18961921

18971922
StatsPlots.scatter!(fill(0,1,1),
1898-
label = "",
1899-
marker = :rect,
1900-
markerstrokecolor = :white,
1901-
markerstrokewidth = 0,
1902-
markercolor = :white,
1903-
linecolor = :white,
1904-
linewidth = 0,
1905-
framestyle = :none,
1906-
legend = :inside)
1923+
label = "",
1924+
marker = :rect,
1925+
markerstrokecolor = :white,
1926+
markerstrokewidth = 0,
1927+
markercolor = :white,
1928+
linecolor = :white,
1929+
linewidth = 0,
1930+
framestyle = :none,
1931+
legend = :inside)
19071932

19081933
has_impact_dict = Dict()
19091934
variable_dict = Dict()

0 commit comments

Comments
 (0)