Skip to content

Commit

Permalink
Fix error in tests and add a test for violinplot
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulinaMartin96 committed Jul 29, 2021
1 parent cf89757 commit 1bb0f93
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
16 changes: 5 additions & 11 deletions src/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const supportedplots = push!(collect(keys(translationdict)), :mixeddensity, :cor
barbounds = (-Inf, Inf),
maxlag = nothing,
append_chains = false,
sections = chains.name_map[:parameters],
par_sections = chains.name_map[:parameters],
combined = true
)
st = get(plotattributes, :seriestype, :traceplot)
Expand Down Expand Up @@ -69,28 +69,22 @@ const supportedplots = push!(collect(keys(translationdict)), :mixeddensity, :cor
ac_mat = convert(Array, ac)
val = colordim == :parameter ? ac_mat[:, :, i]' : ac_mat[i, :, :]
_AutocorPlot(lags, val)
elseif st supportedplots
translationdict[st](c, val)
else
range(c), val
end

total_chains = i
if st == :violinplot
elseif st == :violinplot
n_iter, n_par, n_chains = size(chains)
if combined
colordim := :chain
par = string.(reshape(repeat(sections, inner = n_iter), n_iter, n_par))[:,i]
par = string.(reshape(repeat(par_sections, inner = n_iter), n_iter, n_par))[:,i]
val = Array(chains)[:,i]
_ViolinPlot(par, val)
elseif combined == false
if colordim == :chain
par_names = ["$(sections[i]).Chain $j" for i in 1:n_par, j in 1:n_chains]
par_names = ["$(par_sections[i]).Chain $j" for i in 1:n_par, j in 1:n_chains]
pars = string.(reshape(repeat(vec(par_names), inner = n_iter), (n_iter, n_par, n_chains)))
val = chains.value[:,i,:]
par = pars[:,i,:]
elseif colordim == :parameter
par_vec = repeat(sections, inner = n_iter)
par_vec = repeat(par_sections, inner = n_iter)
pars = string.(reshape(repeat(par_vec, n_chains, 1), (n_iter, n_par, n_chains)))
val = chains.value[:,:,i]
par = pars[:,:,i]
Expand Down
17 changes: 10 additions & 7 deletions test/plot_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,40 @@ Logging.disable_logging(Logging.Warn)
println("traceplot")
display(traceplot(chn, 1))
println()

println("meanplot")
display(meanplot(chn, 1))
println()

println("density")
display(density(chn, 1))
display(density(chn, 1, append_chains=true))
println()

println("autocorplot")
display(autocorplot(chn, 1))
println()

#ps_contour = plot(chn, :contour)

println("histogram")
display(histogram(chn, 1))
println()

println("\nmixeddensity")
display(mixeddensity(chn, 1))


println("violinplot")
display(violinplot(chn))
println()
# plotting combinations
display(plot(chn))
display(plot(chn, append_chains=true))
display(plot(chn, seriestype = (:mixeddensity, :autocorplot)))

# Test plotting using colordim keyword
display(plot(chn, colordim = :parameter))

# Test if plotting a sub-set work.s
display(plot(chn, 2))
display(plot(chn, 2, colordim = :parameter))
Expand Down

0 comments on commit 1bb0f93

Please sign in to comment.