In R/waterfalls, when fill_by_sign = TRUE
, the positive columns fill in 'green' and negative columns fill in 'red'。If I want positive columns fill in 'white', negative columns fill in 'pink',how can i do it ? Thanks!
library(waterfalls)
plot_data <- data.frame(category = letters[1:5],
value = c(1, -0.2, 0.3, -0.1, -0.15))
waterfall(.data = plot_data,
fill_by_sign = TRUE,
calc_total = TRUE,
total_axis_text='total')
I had the same issue. I solved it by creating a vector that checks the sign of the value and assigns a color based on the sign. Then you can feed that into the fill_colors argument.
color_vector <- ifelse(plot_data$value > 0, "white", "pink")
waterfall(.data = plot_data,
fill_by_sign = FALSE,
fill_colours = color_vector,
calc_total = TRUE,
total_axis_text='total')