install.packages('ggplot2') library(ggplot2) install.packages('viridis') library(viridis) #Color map con colores por defecto ggplot(mpg, aes(displ, hwy)) + geom_jitter(aes(color = drv),size = 3, height = 5, weight = 5) #Color map con la paleta de colores "Set1" ggplot(mpg, aes(displ, hwy)) + geom_jitter(aes(color =drv),size = 3, height = 5) + #scale_color_brewer(palette = "Set1") #scale_color_brewer(palette = "Greens") #scale_color_viridis(discrete=TRUE, option="inferno") #Colores especificados a mano library(ggplot2) ggplot(mtcars, aes(x=drat)) + geom_density( color="chartreuse", #fill="#69b3a2", #código hexadecimal fill = colors()[456], #números de colores #fill = rgb(1.0, 0.4, 0.2, 0.5), #valores entre 0 y 1 de red, green, blue y alpha (transparencia) size=2 ) #Cambiando la escala de colores con ggplot2 p <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + geom_point(size=6) p # Escala de grises p + scale_color_grey() #color brewer p + scale_color_brewer(palette = "Spectral") #color viridis p + scale_colour_viridis_d(option="plasma")#discrete=TRUE, option="plasma") #ver ?scale_color_viridis para ver otras "option" #https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html#the-color-scales install.packages("viridis") library(viridis) library(ggplot2) ggplot(data.frame(x = rnorm(10000), y = rnorm(10000)), aes(x = x, y = y)) + geom_hex() + coord_fixed() + #scale_fill_viridis() + theme_bw() scale_fill_viridis(option="magma") + theme_bw()