When I customize colours with scale_fill_manual(), the colours in the logo are not the exact colours specified. For example, a red "#FF0000" does not result in the "#FF0000" red. It seems that the colours' hue gets somehow modified to be less saturated or something. Is there a way to bypass this modification and impose exact colours?
Here is a minimal example, where the text blue and red are right, but the blue and red of the nucleotides should be the same, and it is obviously different.
Thank you!
library(ggplot2)
library(gglogo)
position = c(1, 1, 1, 1, 2, 2, 2, 2)
element = c("A", "C", "G", "U", "A", "C", "G", "U")
freq = c(0.27, 0.26, 0.24, 0.23, 0.26, 0.27, 0.23, 0.24)
d = data.frame(position, element, freq)
figure = ggplot(data=d) +
geom_logo(aes(x=position, y=freq, label=element, fill=element), position="classic") +
scale_fill_manual(values=c("#00FF00", "#FFFFFF", "#FF0000", "#0000FF")) +
annotate("text", x=1.5, y=0.875, label="This text is in #FF0000 RED", size=9, fontface="bold", colour="#FF0000") +
annotate("text", x=1.5, y=0.625, label="This text is in #0000FF BLUE", size=9, fontface="bold", colour="#0000FF")
pdf("minimal_example.pdf")
print(figure)
dev.off()
minimal_example.pdf
When I customize colours with scale_fill_manual(), the colours in the logo are not the exact colours specified. For example, a red "#FF0000" does not result in the "#FF0000" red. It seems that the colours' hue gets somehow modified to be less saturated or something. Is there a way to bypass this modification and impose exact colours?
Here is a minimal example, where the text blue and red are right, but the blue and red of the nucleotides should be the same, and it is obviously different.
Thank you!
library(ggplot2)
library(gglogo)
position = c(1, 1, 1, 1, 2, 2, 2, 2)
element = c("A", "C", "G", "U", "A", "C", "G", "U")
freq = c(0.27, 0.26, 0.24, 0.23, 0.26, 0.27, 0.23, 0.24)
d = data.frame(position, element, freq)
figure = ggplot(data=d) +
geom_logo(aes(x=position, y=freq, label=element, fill=element), position="classic") +
scale_fill_manual(values=c("#00FF00", "#FFFFFF", "#FF0000", "#0000FF")) +
annotate("text", x=1.5, y=0.875, label="This text is in #FF0000 RED", size=9, fontface="bold", colour="#FF0000") +
annotate("text", x=1.5, y=0.625, label="This text is in #0000FF BLUE", size=9, fontface="bold", colour="#0000FF")
pdf("minimal_example.pdf")
print(figure)
dev.off()
minimal_example.pdf