Use the scale_fill_gradient
function 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")
Theeasiestwaytouseitistodefinewhichcoloristhelowerlimitofyourscale(low
)andwhatistheupperlimit(high
).ThecolorsarereportedintheRGB(Red,Green,Blue)hexadecimalpattern.Briefly,thispatterndefineseachcolorwithacodeoftheform#RRGGBB
,where
RRisahexadecimalnumberbetween00andFF,thusallowing256levelsofred
GGisahexadecimalnumberbetween00andFF,thusallowing256levelsofgreen
BBisahexadecimalnumberbetween00andFF,thusallowing256levelsofblue
SowhenIputlow="FFFFFF"
, I'm saying that I want the maximum red, green, and blue in my color. The result of this is white, as this color is the blend of all other colors.
On the other hand, when I put high="FF0000"
, I'm saying that I want the maximum red and the minimum green and blue in my color. The result is pure red.