Use the function scale_fill_gradient
for this:
ggplot(data=dados, aes(x=Freq, y=Tipo, fill=Freq)) +
geom_label(label=rownames(dados), color="black", size=3) +
labs(x = "Frequência", y = "Tipo") +
scale_fill_gradient(low="#FFFFFF", high="#FF0000")
The easiest way to use it is to define which color is the lower limit of your scale (low
) and what is the upper limit (high
). Colors are displayed in the RGB standard (Red, GReen, BLue) hexadecimal. Briefly, this pattern defines each color with a shape code #RRGGBB
, in which
RR is a hexadecimal number between 00 and FF, thus allowing 256 levels of red
GG is a hexadecimal number between 00 and FF, thus allowing 256 levels of green
BB is a hexadecimal number between 00 and FF, thus allowing 256 levels of blue
So when I put low="FFFFFF"
, I’m saying I want the most red, green and blue in my color. The result of this is white, because this color is the mixture of all other colors.
On the other hand, when I put high="FF0000"
, I am saying I want the maximum of red and the minimum of green and blue in my color. The result of this is pure red.
Very good, thank you.
– Thiago Fernandes