4
4
@shorthands pooleddensity
5
5
@shorthands traceplot
6
6
@shorthands corner
7
+ @shorthands violinplot
7
8
8
9
struct _TracePlot; c; val; end
9
10
struct _MeanPlot; c; val; end
10
11
struct _DensityPlot; c; val; end
11
12
struct _HistogramPlot; c; val; end
12
13
struct _AutocorPlot; lags; val; end
14
+ struct _ViolinPlot; parameters; val; end
13
15
14
16
# define alias functions for old syntax
15
17
const translationdict = Dict (
@@ -18,7 +20,8 @@ const translationdict = Dict(
18
20
:density => _DensityPlot,
19
21
:histogram => _HistogramPlot,
20
22
:autocorplot => _AutocorPlot,
21
- :pooleddensity => _DensityPlot
23
+ :pooleddensity => _DensityPlot,
24
+ :violinplot => _ViolinPlot
22
25
)
23
26
24
27
const supportedplots = push! (collect (keys (translationdict)), :mixeddensity , :corner )
184
187
ar = collect (Array (corner. c. value[:, corner. parameters,i]) for i in chains (corner. c))
185
188
RecipesBase. recipetype (:cornerplot , vcat (ar... ))
186
189
end
190
+
191
+ @recipe function f (
192
+ chains:: Chains ;
193
+ sections = chains. name_map[:parameters ],
194
+ combined = true
195
+ )
196
+
197
+ st = get (plotattributes, :seriestype , :traceplot )
198
+ if st == :violinplot
199
+ if combined
200
+ parameters = string .(sections)
201
+ val = Array (chains)[:, ]
202
+ _ViolinPlot (parameters, val)
203
+
204
+ elseif combined == false
205
+ data = Array (chains, append_chains = false )
206
+ parameters = vec ([" param $(sections[i]) .Chain $j "
207
+ for i in 1 : length (sections),
208
+ j in 1 : length (data)])
209
+ val_vec = vec ([data[j][:,i] for i in 1 : length (sections), j in 1 : length (data)])
210
+ n_iter = length (val_vec[1 ])
211
+ n_chains = length (val_vec)
212
+ val = zeros (Float64, n_iter, n_chains)
213
+ for i in 1 : n_iter
214
+ for j in 1 : n_chains
215
+ val[i,j] = val_vec[j][i]
216
+ end
217
+ end
218
+ _ViolinPlot (parameters, val[:,])
219
+ else
220
+ error (" Symbol names are interpreted as parameter names, only compatible with " ,
221
+ " `colordim = :chain`" )
222
+ end
223
+ end
224
+ end
225
+
226
+ @recipe function f (p:: _ViolinPlot )
227
+ seriestype := :violin
228
+ xaxis --> " Parameter"
229
+ p. parameters, p. val
230
+ # [collect(skipmissing(p.val[:,k])) for k in 1:size(p.val)]
231
+ end
0 commit comments