JuliaAcademy / DataScience

Data Science in Julia course for JuliaAcademy.com, taught by Huda Nassar
https://juliaacademy.com/p/julia-for-data-science
MIT License
488 stars 256 forks source link

Visualization notebook throws an error when annotating both sides of violin plots #34

Open daviddoji opened 3 years ago

daviddoji commented 3 years ago

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 :)

DarioSlaifsteinSk commented 1 year ago

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.