echarts4r icon indicating copy to clipboard operation
echarts4r copied to clipboard

Grouped box plot with multiple variables

Open guybrettrobertson opened this issue 2 years ago • 4 comments

Is there a way to create a grouped box plot with multiple grouping variables using {echarts4r}?

I would like to create a grouped box plot with multiple variables comparable to this {ggplot2} plot: https://www.r-graph-gallery.com/265-grouped-boxplot-with-ggplot2.html unnamed-chunk-1-1

I have tried the following:

variety = rep(LETTERS[1:7], each=40)
treatment = rep(c("high","low"),each=20)
note = seq(1:280)+sample(1:150, 280, replace=T)

data.frame(variety, treatment ,  note) |>
  echarts4r::group_by(variety, treatment) |>
  echarts4r::e_charts() |>
  echarts4r::e_boxplot(note) |>
  echarts4r::e_legend()

But it gives me this: Rplot

I have also tried using e_add_nested but it doesn't seem to work for boxplots.

guybrettrobertson avatar Feb 25 '22 11:02 guybrettrobertson

I just noticed that has already come up in issue 253 but no clean solution was available at the time. Have any developments been made on this?

guybrettrobertson avatar Feb 25 '22 11:02 guybrettrobertson

I would love this feature too. I've been using bar charts as a workaround (where the multiple grouping works as expected), but often boxplots are just so much more appropriate. :)

sandra-ab avatar Jul 12 '22 13:07 sandra-ab

#253

JohnCoene avatar Jul 21 '22 04:07 JohnCoene

Created a gist function to do it -> https://gist.github.com/munoztd0/c860717d1f29e8a1b9114c46e945202e

https://github.com/JohnCoene/echarts4r/issues/253#issuecomment-1204012312

munoztd0 avatar Aug 03 '22 14:08 munoztd0