DataScience
DataScience copied to clipboard
Visualization notebook throws an error when annotating both sides of violin plots
When executing the last cell of the "Plot 1: Symmetric violin plots and annotations" section, the notebook throws the following error:
MethodError: no method matching Shape(::Vector{Any}, ::Vector{Any})
Closest candidates are:
Shape(::AbstractVector{T} where T) at /opt/julia/packages/Plots/FKcum/src/components.jl:30
Stacktrace:
[1] top-level scope
@ In[15]:23
[2] eval
@ ./boot.jl:360 [inlined]
[3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1094
I'm using Julia 1.6.0. Same happens to you apparently :)
You need to erase/comment the following lines:
plot!(Shape([],[]),color=6,label=yi)
the Shape method there doesn't work anymore.
my workaround to plot the legend correctly was:
years_of_interst = ["2010-02","2020-02"]
...
if si==states_of_interest[end]
violin!([si], curprices,alpha=0.8,side=:right,color=7,label=yi)
else
violin!([si], curprices,alpha=0.8,side=:right,color=7,label="")
end
same for the other year. Check that I changed the type of the year_of_interest so that the label kwarg works.