violin

violin(data, grp=[]; pos=nothing, kwargs...)

Draw a violin plot that is similar to a box plot, with the addition of a kernel density plot on each side. The input data can take several different forms.

violin(data::AbstractVector{<:Real}; kwargs…)

Draws a single violin. Options in kwargs provide fine settings for the violin

violin(data::AbstractVector{<:Real}, grp::AbstractVector, …) Use the categorical vector (made of integers or text strings) grp break down a the data column vector in cathegories (groups).

violin(data::AbstractMatrix{<:Real}; pos=Vector{<:Real}, …) where pos is a coordinate vector (or a single location when data is a vector) where to plot the boxes. Default plots them at 1:n_boxes or 1:n_groups.

violin(data::GMTdatset{<:Real}; pos=Vector{Real}(), …) Like the above case but the input data is stored in a GMTdataset

violin(data::Vector{Vector{<:Real}}; pos=Vector{Real}(), …) Similar to the Matrix case but here each data vector used to compute the statistics can have a different number of points. There will be as many boxplots as length(data)

violin(data::Array{T<:Real,3}; pos=Vector{Real}(), groupwidth=0.75, ccolor=false, …) Draws G groups of violins of N columns boxes. - groupWidth: Specify the proportion of the x-axis interval across which each x-group of boxes should be spread. The default is 0.75. - ccolor: Logical value indicating whether the groups have constant color (when fill=true is used) or have variable color (the default). - fill: If fill=true paint the boxes with a pre-defined color scheme. Otherwise, give a list of colors to paint the boxes. - fillalpha: When the fill option is used, we can set the transparency of filled violins with this option that takes in an array (vec or 1-row matrix) with numeric values between [0-1] or ]1-100], where 100 (or 1) means full transparency. - pos: a coordinate vector where to plot the boxes. Default plots them at 1:n_boxes or 1:n_groups. - split: If true, the groups that have two elements will be plotted with the left-side of one and the right side of the other. For groups that have other number of elements this option is ignored. - ticks or xticks or yticks: A tuple with annotations interval and labels. E.g. xticks=(1:5, [“a”, “b”, “c”, “d”]) where first element is an AbstractArray and second an array or tuple of strings or symbols. - separator: If = true plot a black line separating the groups. Otherwise provide the pen settings of those lines.

violin(data::Vector{Vector{Vector{<:Real}}}, …) Like the above but here the groups (length(data)) can have a variable number of elements and each have its own size.

This module is a subset of plot. So not all (fine) controlling parameters are not listed here. For the finest control, user should consult the plot module.

Examples

Create a plot with 8 violins colored with the default colors.

using GMT
violin(randn(100,8), fill=true, show=true)

Now add boxplot, scatter and outliers to a plot similar to above. The outliers show as black stars.

using GMT
violin(randn(100,8), fill=true, boxplot=true, scatter=true, outliers=true, show=true)

And a group example with red dashed separator lines.

using GMT
vvv = [[randn(50), randn(30)], [randn(40), randn(48), randn(45)], [randn(35), randn(43)]];
violin(vvv, fill=true, boxplot=true, separator=(:red, :dash), scatter=true, outliers=true, show=true)