Why the color changes when the area of one circle is 0 ("A" = 0) compared to if it is 0.1 ("A" = 0.1) --> compare example 1 and 2. Also if A and B is 0, the circle is black instead of green (see example 3)..
library(eulerr)
# example 1
fit <- euler(c("A" = 0.1, "B" = 10, "A&B" = 5))
p1 <- plot(fit,
fills = list(fill = c("black", "blue", "green")),
labels = F)
p1
# example 2
fit <- euler(c("A" = 0, "B" = 10, "A&B" = 5))
p2 <- plot(fit,
fills = list(fill = c("black", "blue", "green")),
labels = F)
p2
# example 3
fit <- euler(c("A" = 0, "B" = 0, "A&B" = 5))
p3 <- plot(fit,
fills = list(fill = c("black", "blue", "green")),
labels = F)
p3
Edit:
I have found a work around with this here (see below). But the order of the colors seems to behave very weird. A is supposed to be black, B --> blue and A&B --> green. If none is 0 this is the correct order --> c("black", "blue", "green"). But if either A or B is 0 then the order is different, basically just how they appear from left to right in the graph. weird....
combo <- c(A=1, B = 10, "A&B" = 1)
fit <- euler(combo)
p <- plot(fit,
fills = list(fill =
if (combo["A"] == 0) {
c("green", "blue")
} else if (combo["B"] == 0) {
c("black", "green")
} else {
c("black", "blue", "green")
}
),
labels = F)
p
The colours are being used in order. If
A=0
then there is nothing to fill forA
, so the area forB
is filled with the first colour (black), and the area forA&B
with the second colour (blue
). In the third example,A
andB
both have no fill soA&B
is filled with the first colour instead.The simplest solution is just to remove a colour (or multiple) from the vector if you have a value of 0. Eg.