JuliaPlots / StatsPlots.jl

Statistical plotting recipes for Plots.jl
Other
437 stars 88 forks source link

boxplot with weights #238

Open jo-fleck opened 5 years ago

jo-fleck commented 5 years ago

I have household income data in each US state with household weights so that the income distribution is representative at the state level.

Is there a way to use weights with boxplot?

(I cannot multiply each income with the household weight before plotting because this would affect the value of the max and min.)

Thanks for hints and suggestions!

mkborregaard commented 5 years ago

It should be easy to add - see https://github.com/JuliaPlots/StatsPlots.jl/pull/232

jo-fleck commented 5 years ago

Is this already implemented?

I just updated StatsPlots and tried

@df df boxplot(:var1, :var2, weights(:varweights))

No effect (also no error).

mkborregaard commented 5 years ago

No it's not implemented yet, but take a look at the implementation in the PR. The syntax, when it works, would be @df df boxplot(:var1, :var2, weights = :varweights), as we're using the Plots convention of using a keyword, rather than the StatsBase convention of dispatching on the weight vector.

jo-fleck commented 5 years ago

Ah got it now. I'll have a look.

@mkborregaard I'll try to modify the boxplot code and submit a PR. Can I contact you if I have questions? (I haven't contributed to StatsPlots yet.)

mkborregaard commented 5 years ago

Yes for sure, the easiest thing is to tag me here