color of intersection not changes for some intersections
moglideveloper opened this issue · 2 comments
moglideveloper commented
In the below r script, only e intersection color changes to pink, but f and g intersection color doesn't changes to red and purple.
library(eulerr)
diag = euler(c("A" = 1, "B" = 4, "C" = 3, "D" = 2,
"A&B" = 0.25, "C&B" = 1, "C&D" = 1.8
))
plottedDiag = plot(diag,
edges = FALSE,
fills = c("yellow", "green", "orange", "skyblue", "pink", "red", "purple"),
labels = c("", "", "", "", "", "", ""),
#below is mandatory to generate intersection
#tag.number.x
quantities = list(type = c('counts', "percent")),
)
#debugging variable starts here
cc=plottedDiag$children$canvas.grob$children$diagram.grob.1$children$tags$children
#debugging variable ends here
plottedDiag$children$canvas.grob$children$diagram.grob.1$children$tags$children$tag.number.1$children$tag.quantity.1$label = "a"
plottedDiag$children$canvas.grob$children$diagram.grob.1$children$tags$children$tag.number.2$children$tag.quantity.2$label = "b"
plottedDiag$children$canvas.grob$children$diagram.grob.1$children$tags$children$tag.number.3$children$tag.quantity.3$label = "c"
plottedDiag$children$canvas.grob$children$diagram.grob.1$children$tags$children$tag.number.4$children$tag.quantity.4$label = "d"
plottedDiag$children$canvas.grob$children$diagram.grob.1$children$tags$children$tag.number.5$children$tag.quantity.5$label = "e"
plottedDiag$children$canvas.grob$children$diagram.grob.1$children$tags$children$tag.number.6$children$tag.quantity.6$label = "f"
plottedDiag$children$canvas.grob$children$diagram.grob.1$children$tags$children$tag.number.7$children$tag.quantity.7$label = "g"
plottedDiag
jolars commented
library(eulerr)
diag = euler(c("A" = 1, "B" = 4, "C" = 3, "D" = 2,
"A&B" = 0.25, "C&B" = 1, "C&D" = 1.8))
plot(
diag,
fills = c(
"yellow", # a
"green", # b
"orange", # c
"skyblue", # d
"pink", # a&b
"white", # a&c
"white", # a&d
"red", # b&c
"purple" # b&d etc
)
)
The reason for this behavior is to have reproducible color settings. Otherwise the colors risk changing just because in one fit one intersection disappears.
But I understand that this is confusing and I think what the function really should do is to allow a named vector of fills, so that you can set fills = c("B&C" = "purple")
for instance.
moglideveloper commented
got it :).
Thanks