From 1bb0f93add25d92d772f69c739e1cf298e6b3453 Mon Sep 17 00:00:00 2001 From: Paulina Martin Date: Wed, 28 Jul 2021 21:59:49 -0500 Subject: [PATCH] Fix error in tests and add a test for violinplot --- src/plot.jl | 16 +++++----------- test/plot_test.jl | 17 ++++++++++------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/plot.jl b/src/plot.jl index 4d3a44c9..fc1e3232 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -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) @@ -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] diff --git a/test/plot_test.jl b/test/plot_test.jl index 9654ed8c..bb142e5d 100644 --- a/test/plot_test.jl +++ b/test/plot_test.jl @@ -24,29 +24,32 @@ 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)) @@ -54,7 +57,7 @@ Logging.disable_logging(Logging.Warn) # 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))