This is closely related to another question I just asked.
This is my data:
y <- structure(
c(0.5619, 0.4381, 0.7587, 0.2413, 0.8764, 0.1236,
0.9019, 0.0981, 0.9481, 0.0519, 0.99, 0.01),
.Dim = c(2L, 6L), .Dimnames = list(c("FALSE", "TRUE"), NULL)
)
y
# [,1] [,2] [,3] [,4] [,5] [,6]
# FALSE 0.5619 0.7587 0.8764 0.9019 0.9481 0.99
# TRUE 0.4381 0.2413 0.1236 0.0981 0.0519 0.01
The original plot with same colors within each group (blue and red):
barplot(
y, horiz = TRUE, col = c("blue", "red"),
names.arg = c("Overall", paste("Flag", 5:1)), las = 1L,
cex.names = 0.6,
main = "Proportion Dropped Given Each Sample Restriction"
)
I want to change the red right-hand bars for each group, and instead have different colors within each group, something like:
I therefore created a new col
vector with one color for each bar segment:
barplot(
y, horiz =TRUE,
col = c(
"blue", "gold",
"blue", "springgreen",
"blue", "orange",
"blue", "red",
"blue", "white"
),
names.arg = c("Overall", paste("Flag", 5:1)), las = 1L,
cex.names = 0.6,
main = "Proportion Dropped Given Each Sample Restriction"
)
However, only the first two colors in col
(blue and gold) are used and they are recycled 6 times:
Is there any way to get the output I'm looking for?