Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is default color of smooth curve in ggplot2?

Tags:

r

ggplot2

I'd like to make my report using only two colors. I would like to know what's the default color of smooth curve in ggplot2 called so I can name my bar/line/pie accordingly. Thanks.

like image 793
user2639300 Avatar asked Jan 11 '16 14:01

user2639300


People also ask

What are the default colors in ggplot2?

By default, ggplot2 chooses to use a specific shade of red, green, and blue for the bars.

How do you change colors in ggplot?

Change colors manually A custom color palettes can be specified using the functions : scale_fill_manual() for box plot, bar plot, violin plot, etc. scale_color_manual() for lines and points.

What is Geom smooth in R?

The geom smooth function is a function for the ggplot2 visualization package in R. Essentially, geom_smooth() adds a trend line over an existing plot.


1 Answers

Following @Konrad's comment pointing here:

library("ggplot2")
dd <- data.frame(x=1:10,y=1:10)
g1 <- ggplot(dd,aes(x,y))+geom_smooth()
unique(ggplot_build(g1)$data[[1]]$colour)  ## "#3366FF"
plot(1,1,cex=8,pch=16,col="#3366FF")

enter image description here

This is not actually an exact duplicate of emulate ggplot colour palette: if we build a three-category coloured plot plus a smooth we get:

sapply(ggplot_build(g1)$data,function(x) unique(x$colour))
## [[1]]
## [1] "#F8766D" "#00BA38" "#619CFF" # three colours from colour wheel 
## [[2]]
## [1] "#3366FF"    # geom_smooth colour
like image 163
Ben Bolker Avatar answered Oct 18 '22 20:10

Ben Bolker