library(ggxmean)
<- worldbankdata |>
p1 filter(Country == "Angola") |>
ggplot(mapping = aes(x = Cooking, y = Electricity)) +
geom_point() + ggtitle("without geom_y_line")
<- worldbankdata |>
p2 filter(Country == "Angola") |>
ggplot(mapping = aes(x = Cooking, y = Electricity)) +
geom_point() + geom_y_line(alpha = .2) +
ggtitle("with geom_y_line")
|p2 p1
27 geom_y
##geom_y_line{#y_line}
Package
ggxmean (Reynolds 2024)
Description
Create horizontal lines representing the specified value of the y variable across the x values in the data.
Understandable aesthetics
required aesthetics
x
y
optional aesthetics
alpha
, colour
, group
, linetype
, linewidth
See also
Example
27.1 geom_y_mean
Package
ggxmean (Reynolds 2024)
Description
Draw a horizontal line at the mean of y-variable.
Understandable aesthetics
required aesthetics
x
y
optional aesthetics
alpha
, colour
, group
, linetype
, linewidth
See also
geom_line, geom_ribbon geom_y_line
Example
library(ggxmean)
<- worldbankdata |>
p1 filter(Country == "Angola") |>
ggplot(mapping = aes(x = Cooking, y = Electricity)) +
geom_point() + ggtitle("without geom_y_mean")
<- worldbankdata |>
p2 filter(Country == "Angola") |>
ggplot(mapping = aes(x = Cooking, y = Electricity)) +
geom_point() + geom_y_mean(colour="#d95f02") +
ggtitle("with geom_y_mean")
|p2 p1
##geom_ydiff{#ydiff}
Package
ggplot2 (Wickham 2016)
Description
Understandable aesthetics
required aesthetics
x
y
optional aesthetics
alpha
, colour
, group
, linetype
, linewidth
See also
geom_line, geom_ribbon geom_y_line
Example
library(ggxmean)
<- worldbankdata |>
p1 filter(Country == "Angola") |>
ggplot(mapping = aes(x = Cooking, y = Electricity)) +
geom_point() + ggtitle("without geom_ydiff")
<- worldbankdata |>
p2 filter(Country == "Angola") |>
ggplot(mapping = aes(x = Cooking, y = Electricity)) +
geom_point() +
geom_y_mean(col="#d95f02")+ggxmean:::geom_ydiff(colour="#1b9e77") +
ggtitle("with geom_ydiff")
|p2 p1