Skip to content

Commit

Permalink
Correct input variables of _ViolinPlot
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulinaMartin96 committed Jul 8, 2021
1 parent 4674ea5 commit 01d56d5
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,33 +190,37 @@ end

@recipe function f(
chains::Chains;
sections = chains.name_map[:parameters],
sections::Vector{Symbol} = chains.name_map[:parameters],
combined = true
)

st = get(plotattributes, :seriestype, :traceplot)
total_chains = 0
if st == :violinplot
if combined
parameters = string.(sections)
val = Array(chains)[:, ]
n_iter, n_parameters = size(Array(chains))
parameters = string.(repeat(sections, inner = n_iter))
val = vec(Array(chains))
total_chains = Integer(size(chains.value.data)[3])
_ViolinPlot(parameters, val, total_chains)
elseif combined == false
n_parameters = length(sections)
chain_arr = Array(chains, append_chains = false)
parameters = ["param $(sections[i]).Chain $j"
for i in 1:length(sections)
for j in 1:length(chain_arr)]
val_vec = [chain_arr[j][:,i]
for i in 1:length(sections)
for i in 1:n_parameters
for j in 1:length(chain_arr)]
n_iter = length(val_vec[1])
total_chains = length(val_vec)
val = zeros(Float64, n_iter, total_chains)
for i in 1:total_chains
val[:,i] = val_vec[:][i]
end
_ViolinPlot(parameters, val[:,], total_chains)
val = vec(val)
parameters_names = ["param $(sections[i]).Chain $j"
for i in 1:n_parameters
for j in 1:length(chain_arr)]
parameters = string.(repeat(parameters_names, inner = n_iter))
_ViolinPlot(parameters, val, total_chains)
else
error("Symbol names are interpreted as parameter names, only compatible with ",
"`colordim = :chain`")
Expand All @@ -228,7 +232,7 @@ end
@series begin
seriestype := :violin
xaxis --> "Parameter"
size --> (150*p.total_chains, 500)
size --> (200*p.total_chains, 500)
p.parameters, p.val
end

Expand Down

0 comments on commit 01d56d5

Please sign in to comment.