0

I am trying to use fill function in ggboxplot of ggpubr package. But it throws an error:

code used.

library(ggpubr)
data("ToothGrowth")
df <- ToothGrowth

ggboxplot(df, x = "dose", y = "len", fill= c("red", "navy", "green"))

Throws an error:

Error in `purrr::pmap()`:
ℹ In index: 1.
ℹ With name: len.
Caused by error in `if (fill %in% names(data) & is.null(add.params$fill)) ...`:
! the condition has length > 1
Traceback:

1. ggboxplot(df, x = "dose", y = "len", fill = c("red", "navy", 
 .     "green"))
2. do.call(.plotter, .opts)
3. (function (fun, data, x, y, combine = FALSE, merge = FALSE, color = "black", 
 .     fill = "white", title = NULL, xlab = NULL, ylab = NULL, legend = NULL, 
 .     legend.title = NULL, facet.by = NULL, select = NULL, remove = NULL, 
 .     order = NULL, add = "none", add.params = list(), label = NULL, 
 .     font.label = list(size = 11, color = "black"), label.select = NULL, 
 .     repel = FALSE, label.rectangle = FALSE, font.family = "", 
 .     parse = FALSE, ggtheme = theme_pubr(), fun_name = "", group = 1, 
 .     show.legend.text = NA, ...) 

If I remove fill option from the command it run smoothly.

stefan
  • 90,330
  • 6
  • 25
  • 51
  • 1
    Perhaps you want `ggboxplot(df, x = "dose", y = "len", fill = "dose", palette = c("red", "navy", "green"))`? – stefan Mar 02 '23 at 11:27

0 Answers0