Skip to content

Commit

Permalink
Merge pull request JuliaPlots#136 from JuliaPlots/pv/violin
Browse files Browse the repository at this point in the history
fix JuliaPlots#121 : out of bound error with violin and boxplot
  • Loading branch information
Pietro Vertechi authored Mar 22, 2018
2 parents a05f771 + 32bffc6 commit 6957251
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/boxplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ notch_width(q2, q4, N) = 1.58 * (q4-q2)/sqrt(N)

@recipe function f(::Type{Val{:boxplot}}, x, y, z; notch=false, range=1.5, outliers=true, whisker_width=:match)
# if only y is provided, then x will be UnitRange 1:length(y)
if typeof(x) <: UnitRange
x = [getindex(x, plotattributes[:series_plotindex])]
if typeof(x) <: Range
if step(x) == start(x) == 1
x = plotattributes[:series_plotindex]
else
x = [getindex(x, plotattributes[:series_plotindex])]
end
end
xsegs, ysegs = Segments(), Segments()
glabels = sort(collect(unique(x)))
Expand Down
8 changes: 6 additions & 2 deletions src/violin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ end

@recipe function f(::Type{Val{:violin}}, x, y, z; trim=true, side=:both)
# if only y is provided, then x will be UnitRange 1:length(y)
if typeof(x) <: UnitRange
x = [getindex(x, plotattributes[:series_plotindex])]
if typeof(x) <: Range
if step(x) == start(x) == 1
x = plotattributes[:series_plotindex]
else
x = [getindex(x, plotattributes[:series_plotindex])]
end
end
xsegs, ysegs = Segments(), Segments()
glabels = sort(collect(unique(x)))
Expand Down

0 comments on commit 6957251

Please sign in to comment.