Commit 01b18328 authored by MichelJuillard's avatar MichelJuillard
Browse files

mirror axes graph

parent 6412c724
......@@ -615,7 +615,7 @@ function get_smoothed_values(variable_name::String;
return context.results.model_results[1].smoother["alphah"][k,:]
end
function plot(variables;
function plot(variables::Vector{Vector{Float64}};
bar_variable = [],
first_period = 1,
plot_title = "Smoothed value",
......@@ -624,7 +624,9 @@ function plot(variables;
plot_legend_position = :topright)
local myplot
# deal first with bar variable
variables = pushfirst!(variables, bar_variable)
if length(bar_variable) > 0
variables = pushfirst!(variables, bar_variable)
end
for (i, v) in enumerate(variables)
if length(plot_legend) > 0
thislabel = plot_legend[i]
......@@ -659,3 +661,48 @@ function plot(variables;
Plots.savefig(plot_filename)
end
end
function plot(variable::Vector{Float64};
bar_variable = [],
first_period = 1,
plot_title = "Smoothed value",
plot_legend = (),
plot_filename = "",
plot_legend_position = :topright)
local myplot
# deal first with bar variable
if length(plot_legend) > 0
thislabel = plot_legend
else
thislabel = ""
plot_legend_position = false
end
if length(bar_variable) > 0
len = length(bar_variable)
xb = collect(range(first_period, length=len))
myplot = Plots.bar(xb, bar_variable, label = thislabel[1],
legend=plot_legend_position,
title = plot_title)
x = collect(range(first_period, length=length(variable)))
lims = Plots.ignorenan_extrema(myplot[1].attr[:yaxis])
m, M = extrema(variable)
tb = (lims[2] - lims[1])/(M-m)
variable = tb*(variable .- m) .+ lims[1]
Plots.plot!(x, variable, label = thislabel[2],
title = plot_title,
linewidth = 3)
myplot = twinx()
@show (m, M)
myplot = Plots.plot!(myplot, ylims = (m, M))
else
x = collect(range(first_period, length=length(variable)))
Plots.plot(x, variable, label = thislabel[1],
legend=plot_legend_position,
title = plot_title,
linewidth = 3)
end
Plots.display(myplot)
if length(plot_filename) > 0
Plots.savefig(plot_filename)
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment