My data.frame() has 4 columns, the first one with the name of the Installation, the second one with the percentage of corrective work, the 3rd with preventive work and the last one with the percentage of other works.
library(ggplot2)
grafico <- ggplot(taula_final, aes(x = Instal.lació)) +
geom_col(aes(y = Porcentajes_Correctius, fill = "Correctius"), width = 0.7, color = "black") +
geom_col(aes(y = Porcentajes_Preventius, fill = "Preventius"), width = 0.7, color = "black") +
geom_col(aes(y = Porcentajes_Altres, fill = "Altres"), width = 0.7, color = "black") +
scale_fill_manual(values = c("Correctius" = "red", "Preventius" = "green", "Altres" = "orange"), drop = FALSE) +
labs(x = "Instal.lació", y = "Porcentaje", fill = "Tipo de Trabajo") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
print(grafico)
I was expecting that it would fill all the bars to a 100% with the 3 colors, as you see they leave a blank space on top of each bar :(