Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the color of se(confidence interval) of geom_smooth in ggplot2? [duplicate]

Tags:

r

ggplot2

When I set the function, geom_smooth(..., se = TURE), the confidence interval is gray, but I want to set some other color.

Looks like it is a parameter that can not set color in geom_smooth. Should I create a new geom? or are there some ggplot2 extensions can be used? Thank you

like image 944
gery Avatar asked Oct 19 '18 08:10

gery


People also ask

What is the confidence interval in Geom_smooth?

By default, geom_smooth() uses 95% confidence bands but you can use the level argument to specify a different confidence level.

What does se in Geom_smooth do?

se Display confidence interval around smooth (TRUE by default, see level to control.)

What is Stat_smooth in R?

stat_smooth() provides the following variables, some of which depend on the orientation: y or x. predicted value. ymin or xmin. lower pointwise confidence interval around the mean.

What is the GREY area in Geom_smooth?

The grey area [SE=TRUE] would be a zone that covers 95% confidence level [that the values will be within that area]. https://ggplot2.tidyverse.org/reference/geom_smooth.html [Level=95% by default, can be increased to 99%]. Switching it to SE=FALSE hides it.


1 Answers

Since you did not provide example data

ggplot(
    iris, 
    aes(
        x = Sepal.Length, 
        y = Sepal.Width
    )
) + 
    geom_point() + 
    geom_smooth(fill = "red")

1

like image 171
Roman Avatar answered Oct 10 '22 09:10

Roman