Skip to content

Commit 42aab42

Browse files
New Plot: Violin Plot Implementation (#316)
* Resolve merge conflicts for PR, removed violin plot in this commit This commit contains plot.jl from master * Fix error in tests and add a test for violinplot * Implemented Violin Plot * Added tests for Violin plot * Bump MCMCChains version from 7.0.0 to 7.0.1 * Run JuliaFormatter * Added Violin Plot docs * Add violin plot with append_chains = true examples in test and docs * Apply suggested changes from code review * Ran JuliaFormatter again * Disable legends for violin plots --------- Co-authored-by: Shravan Goswami <[email protected]>
1 parent 268886e commit 42aab42

File tree

4 files changed

+281
-76
lines changed

4 files changed

+281
-76
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uuid = "c7f686f2-ff18-58e9-bc7b-31028e88f75d"
33
keywords = ["markov chain monte carlo", "probablistic programming"]
44
license = "MIT"
55
desc = "Chain types and utility functions for MCMC simulations."
6-
version = "7.0.0"
6+
version = "7.0.1"
77

88
[deps]
99
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"

docs/src/statsplots.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,50 @@ histogram(chn)
8383
autocorplot(chn)
8484
```
8585

86+
## Violin
87+
88+
Violin plots are similar to box plots but also show the probability density of the data at different values, smoothed by a kernel density estimator.
89+
90+
```@example statsplots
91+
violinplot(chn) # Plotting parameter 1 across all chains
92+
```
93+
94+
```@example statsplots
95+
violinplot(chn, 1) # Plotting parameter 1 across all chains
96+
```
97+
98+
```@example statsplots
99+
violinplot(chn, :A) # Plotting a specific parameter across all chains
100+
```
101+
102+
```@example statsplots
103+
violinplot(chn, [:C, :B, :A]) # Plotting multiple specific parameters across all chains
104+
```
105+
106+
```@example statsplots
107+
violinplot(chn, 1, colordim = :parameter) # Plotting chain 1 across all parameters
108+
```
109+
110+
```@example statsplots
111+
violinplot(chn, show_boxplot = false) # Plotting all parameters without the inner boxplot
112+
```
113+
114+
You can also aggregate (pool) samples from all chains for a given parameter by using `append_chains = true`. This is useful when you want to visualize the overall posterior distribution without distinguishing between individual chains.
115+
116+
```@example statsplots
117+
violinplot(chn, :A, append_chains = true) # Single parameter, all chains appended
118+
```
119+
120+
```@example statsplots
121+
violinplot(chn, append_chains = true) # All parameters, all chains appended
122+
```
123+
124+
You can also use the `plot` function with `seriestype = :violinplot` or `seriestype = :violin`
125+
126+
```@example statsplots
127+
plot(chn, seriestype = :violin)
128+
```
129+
86130
## Corner
87131

88132
```@example statsplots

0 commit comments

Comments
 (0)