JuliaPlots / StatsMakie.jl

Statistical visualizations based on high performance plotting package Makie
Other
48 stars 10 forks source link

Support categorical axes for sample plot types #106

Closed sethaxen closed 4 years ago

sethaxen commented 4 years ago

This PR adds a new conversion trait SampleBased that behaves similarly to PointBased but does not make points. This supports categorical axes. For now the only plot types deemed SampleBased are Violin and BoxPlot.

Some examples:

julia> a = repeat(["a", "b", "c", "d", "e"], inner = 20)

julia> b = 1:100

julia> boxplot(a, b)

test

However, it looks like the information about tick labels is lost when using MultiplePlot:

julia> using RDatasets

julia> d = dataset("Ecdat","Fatality");

julia> first(d, 1)
1×10 DataFrame
│ Row │ State │ Year  │ MRAll   │ BeerTax │ MLDA    │ JailD        │ Comserd      │ VMiles  │ Unrate  │ Perinc  │
│     │ Int32 │ Int32 │ Float64 │ Float64 │ Float64 │ Categorical… │ Categorical… │ Float64 │ Float64 │ Float64 │
├─────┼───────┼───────┼─────────┼─────────┼─────────┼──────────────┼──────────────┼─────────┼─────────┼─────────┤
│ 1   │ 1     │ 1982  │ 2.12836 │ 1.53938 │ 19.0    │ no           │ no           │ 7.23389 │ 14.4    │ 10544.2 │

julia> boxplot(Data(d), :JailD, :BeerTax)

test2

The function categoric_position is just a placeholder, as a method with a signature like this should be in AbstractPlotting.

codecov-io commented 4 years ago

Codecov Report

Merging #106 into master will increase coverage by 0.52%. The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #106      +/-   ##
==========================================
+ Coverage   75.49%   76.01%   +0.52%     
==========================================
  Files          16       16              
  Lines         453      467      +14     
==========================================
+ Hits          342      355      +13     
- Misses        111      112       +1
Impacted Files Coverage Δ
src/StatsMakie.jl 100% <ø> (ø) :arrow_up:
src/recipes/violin.jl 100% <100%> (ø) :arrow_up:
src/recipes/boxplot.jl 79.71% <100%> (+0.29%) :arrow_up:
src/group/tables.jl 86.4% <91.66%> (+0.69%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d52f20d...d700999. Read the comment docs.

SimonDanisch commented 4 years ago

Great, thanks a lot :)

piever commented 4 years ago

Thanks a lot for this! I wouldn't worry about the MultiplePlot issue as that will probably be overhauled soon. I've just left a couple of comments concerning categoric_position.

sethaxen commented 4 years ago

I opened https://github.com/JuliaPlots/AbstractPlotting.jl/pull/345 to add the fix for categoric_position to AbstractPlotting and removed it from this PR.

asinghvi17 commented 4 years ago

I'll tag a new AbstractPlotting version after https://github.com/JuliaPlots/AbstractPlotting.jl/pull/346, so you might want to open a compat PR to explicitly require that or above.