Adding support for arrays in violin-plot
This commit is contained in:
parent
a5ceea153d
commit
f7c06da93e
@ -719,24 +719,39 @@ end
|
||||
|
||||
# create a list of shapes, where each shape is a single boxplot
|
||||
shapes = Shape[]
|
||||
groupby = extractGroupArgs(d[:x])
|
||||
|
||||
for (i, glabel) in enumerate(groupby.groupLabels)
|
||||
|
||||
# get the edges and widths
|
||||
y = d[:y][groupby.groupIds[i]]
|
||||
widths, centers = violin_coords(y, trim=trim)
|
||||
legend --> false
|
||||
|
||||
if length(d[:x])==1
|
||||
widths, centers = violin_coords(d[:y], trim=trim)
|
||||
# normalize
|
||||
widths = _box_halfwidth * widths / maximum(widths)
|
||||
|
||||
# make the violin
|
||||
xcenter = discrete_value!(d[:subplot][:xaxis], glabel)[1]
|
||||
xcenter = discrete_value!(d[:subplot][:xaxis], d[:x][1])[1]
|
||||
xcoords = vcat(widths, -reverse(widths)) + xcenter
|
||||
ycoords = vcat(centers, reverse(centers))
|
||||
push!(shapes, Shape(xcoords, ycoords))
|
||||
else
|
||||
groupby = extractGroupArgs(d[:x])
|
||||
for (i, glabel) in enumerate(groupby.groupLabels)
|
||||
|
||||
# get the edges and widths
|
||||
y = d[:y][groupby.groupIds[i]]
|
||||
widths, centers = violin_coords(y, trim=trim)
|
||||
|
||||
# normalize
|
||||
widths = _box_halfwidth * widths / maximum(widths)
|
||||
|
||||
# make the violin
|
||||
xcenter = discrete_value!(d[:subplot][:xaxis], glabel)[1]
|
||||
xcoords = vcat(widths, -reverse(widths)) + xcenter
|
||||
ycoords = vcat(centers, reverse(centers))
|
||||
push!(shapes, Shape(xcoords, ycoords))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# d[:plotarg_overrides] = KW(:xticks => (1:length(shapes), groupby.groupLabels))
|
||||
seriestype := :shape
|
||||
# n = length(groupby.groupLabels)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user