# install.packages("devtools")
#devtools::install_github("EvaMaeRey/ggxmean")
26 geom_x
26.1 geom_xmax
Package
ggxmean (Reynolds 2024)
Description
Draw vertical line at the max of x.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, linetype
, size
See also
geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
library(ggxmean)
drop_na(worldbankdata) |>
ggplot(aes(x = Cooking)) +
geom_histogram(binwidth = 5, alpha=0.5, fill = "#1b9e77", color = "black") +
geom_xmax(color = "#d95f02", linetype = "dashed", size = 1)
26.2 geom_xmin
Package
ggxmean (Reynolds 2024)
Description
Draw vertical line at the min of x.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color, linetype , size
See also
geom_xmax, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example 1
drop_na(worldbankdata) |>
ggplot(aes(x = Cooking)) +
geom_histogram(binwidth = 5, fill = "#1b9e77", color = "black") +
geom_xmin(color = "#d95f02", linetype = "dashed", size = 1)
26.3 geom_x_median
Package
ggxmean (Reynolds 2024)
Description
Place point at median of x.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, linetype
, size
See also
geom_xmax, geom_xmin, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
drop_na(worldbankdata) |>
ggplot(aes(x = Cooking)) +
geom_histogram(binwidth = 5, fill = "#1b9e77", color = "black") +
geom_x_median(color = "#d95f02", linetype = "dashed", size = 1)
26.4 geom_x_mean
Package
ggxmean (Reynolds 2024)
Description
Place point at mean of x.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, linetype
, size
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
drop_na(worldbankdata) |>
ggplot(aes(x = Cooking)) +
geom_histogram(binwidth = 5, fill = "#1b9e77", color = "black") +
geom_x_mean(color = "#d95f02", linetype = "dashed", size = 1)
26.5 geom_x_mean_label
Package
ggxmean (Reynolds 2024)
Description
Place point at mean of x and label.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, linetype
, size
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
drop_na(worldbankdata) |>
ggplot(aes(x = Cooking)) +
geom_histogram(binwidth = 5, fill = "#1b9e77", color = "black") +
geom_x_mean_label(color = "#d95f02", linetype = "dashed", size = 1)
26.6 geom_x_percentile
Package
ggxmean (Reynolds 2024)
Description
Lines are drawn at the percentile value of x.
Understandable aesthetics
required aesthetics
x
optional aesthetics
percentile
, color
, linetype
, size
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
quantile(worldbankdata$Cooking, na.rm = T)
0% 25% 50% 75% 100%
0.00 27.30 84.75 100.00 100.00
drop_na(worldbankdata) |>
ggplot(mapping = aes(x = Cooking)) +
geom_histogram(binwidth = 5, fill = "#1b9e77", color = "black") +
geom_x_percentile(percentile = c( 25,50, 75), linetype = "dashed", size = 1, color = "#d95f02") +
labs(title = "25th, 50th and 75th percentiles", x = "Cooking", y = "Frequency")
26.7 geom_xy_means
Package
ggxmean (Reynolds 2024)
Description
Place point at the intersection point of mean of x and mean of y.
Understandable aesthetics
required aesthetics
x
, y
optional aesthetics
position
, color
, size
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
drop_na(worldbankdata) |>
ggplot() +
aes(x = Electricity, y = Cooking) +
geom_point(color = "black", size = 1) +
::geom_xy_means(color = "red", size = 5) +
ggxmeanlabs(title = "", x = "Electricity", y = "Cooking")
Example 2
library(ggxmean)
<- worldbankdata |>
a1 ggplot(aes(x = Income, y = Cooking)) +
geom_xy_means(na.rm=TRUE, col="red", size=4) +
ggtitle("a1: geom_xy_means only")
<- worldbankdata |>
a2 ggplot(aes(x = Income, y = Cooking)) +
geom_point(alpha=0.5) +
geom_xy_means(na.rm=TRUE, col="red", size=4) +
ggtitle("a2: geom_points and geom_xy_means")
|a2 a1
Warning: Removed 6047 rows containing missing values or values outside the scale range
(`geom_point()`).
26.8 geom_x_line
Package
ggxmean (Reynolds 2024)
Description
Lines defined by values of x.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, size
, alpha
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
<- drop_na(worldbankdata) |>
p1 filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity)) + geom_point()+
labs(title = "geom_point only", x = "Cooking", y = "Electricity")
<- drop_na(worldbankdata) |>
p2 filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity)) + geom_point()+
geom_x_line(color = '#1b9e77', size = 0.9) +
labs(title = "geom_point and geom_x_line", x = "Cooking", y = "Electricity")
|p2 p1
26.9 geom_xdiff
Package
ggxmean (Reynolds 2024)
Description
Place lines from each point to mean x.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, size
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
<- drop_na(worldbankdata) |>
p1 filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity)) + geom_point() + ggxmean:::geom_xdiff() +
labs(title = "", x = "Cooking", y = "Electricity") +
theme(plot.title = element_text(hjust = 0.5, face = "bold"),
plot.subtitle = element_text(hjust = 0.5),
plot.caption = element_text(hjust = 0.5), legend.position = "none",
axis.title.x = element_text(margin = margin(t = 10)),
axis.title.y = element_text(margin = margin(r = 10)))
<- drop_na(worldbankdata) |>
p2 filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity)) + geom_x_mean() +
geom_point() + ggxmean:::geom_xdiff() +
labs(title = "geom_x_mean, geom_point and geom_xdiff", x = "Cooking", y = "Electricity") +
theme(plot.title = element_text(hjust = 0.5, face = "bold"),
plot.subtitle = element_text(hjust = 0.5),
plot.caption = element_text(hjust = 0.5), legend.position = "none",
axis.title.x = element_text(margin = margin(t = 10)),
axis.title.y = element_text(margin = margin(r = 10)))
/p2 p1
26.10 geom_x1sd
Package
ggxmean (Reynolds 2024)
Description
Represents one standard deviation.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, alpha
, fill
, linetype
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
drop_na(worldbankdata) |>
filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity)) +
geom_point() +
:::geom_x1sd(color = '#e7298a', fill = '#e7298a') +
ggxmeanlabs(title = "", x = "Cooking", y = "Electricity")
26.11 geom_xydiffsmean
Package
ggxmean (Reynolds 2024)
Description
Draw the results of \[\frac{\sum_{i=1}^{N}(x_i-\bar{x})(y_i-\bar{y})}{N}\]
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, alpha
, fill
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
<- drop_na(worldbankdata) |>
p1 filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity)) +
geom_point() +
:::geom_xydiffsmean(color = '#c51b8a', fill = '#c51b8a', alpha = 0.5) +
ggxmeanlabs(title = "", x = "Cooking", y = "Electricity")
<- drop_na(worldbankdata) |>
p2 filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity)) +
geom_point() + ggxmean:::geom_xdiff(col="#1b9e77") + ggxmean:::geom_ydiff(col="#d95f02")+
:::geom_xydiffsmean(color = '#c51b8a', fill = '#c51b8a', alpha = 0.5) +
ggxmeanlabs(title = "geom_point, geom_xdiff, geom_ydiff, geom_xydiffmean", x = "Cooking", y = "Electricity")
/p2 p1
26.13 geom_xsidedensity
Package
ggside (Landis 2024)
Description
The xside variant of geom_density is geom_xsidedensity.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, fill
, position
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
require(ggside)
drop_na(worldbankdata) |>
filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity, fill = Income)) +
geom_point(size = 1.5) +
geom_xsidedensity(size = 1) +
labs(title = "", x = "Cooking", y = "Electricity") + scale_color_brewer(palette = "Dark2") + scale_fill_brewer(palette = "Dark2")
26.14 geom_xsidefreqpoly
Package
ggside (Landis 2024)
Description
The xside variant of geom_freqpoly is geom_xsidefreqpoly.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, fill
, position
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
require(ggside)
drop_na(worldbankdata) |>
filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity, colour = Income)) +
geom_point(size = 1.5) +
geom_xsidefreqpoly(aes(y=after_stat(count)),binwidth = 500) +
labs(title = "", x = "Cooking", y = "Electricity") + scale_color_brewer(palette = "Dark2") + scale_fill_brewer(palette = "Dark2")
26.15 geom_xsidehistogram
Package
ggside (Landis 2024)
Description
The xside variant of geom_histogram is geom_xsidehistogram.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, fill
, position
, binwidth
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
require(ggside)
drop_na(worldbankdata) %>%
filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) %>%
ggplot(aes(x = Cooking, y = Electricity, colour = Income)) +
geom_point(size = 1.5) +
geom_xsidehistogram(binwidth = 0.1, aes(fill = Income)) +
labs(title = "", x = "Cooking", y = "Electricity") + scale_color_brewer(palette = "Dark2") + scale_fill_brewer(palette = "Dark2")
26.16 geom_xsidepoint
Package
ggside (Landis 2024)
Description
The ggside variants of geom_point is geom_xsidepoint. Projection of points into the x-axis to show the marginal distribution of x.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, fill
, position
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
require(ggside)
drop_na(worldbankdata) |>
filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity, colour = Income)) +
geom_point(size = 1.5) +
geom_xsidepoint(aes(y = Income)) +
labs(title = "", x = "Cooking", y = "Electricity") + scale_color_brewer(palette = "Dark2") + scale_fill_brewer(palette = "Dark2")
26.17 geom_xsideboxplot
Package
ggside (Landis 2024)
Description
The xside variant of geom_boxplot is geom_xsideboxplot. Marginal distribution of x using boxplots
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, fill
, position
, alpha
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_x_margin_arrow, geom_x_margin_point, geom_xsidefunction
Example
require(ggside)
drop_na(worldbankdata) |>
filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity, colour = Income)) +
geom_point(size = 1.5) +
geom_xsideboxplot(aes(y = Income), orientation = "y") +
labs(title = "", x = "Cooking", y = "Electricity") + scale_color_brewer(palette = "Dark2") + scale_fill_brewer(palette = "Dark2")
26.18 geom_x_margin_arrow
Package
ggpp (Aphalo 2024)
Description
Plot small arrows on plot margins in a 2D display. Arrows can be used to highlight specific values along a margin.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, alpha
, position
, xintercept
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_point, geom_xsidefunction
Example
require(ggpp)
drop_na(worldbankdata) |>
filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity, colour = Income)) +
geom_point(size = 1.5) +
geom_x_margin_arrow(xintercept = seq(0, 75, by = 10), size = 1, alpha = 0.8) +
labs(title = "", x = "Cooking", y = "Electricity") + scale_color_brewer(palette = "Dark2") + scale_fill_brewer(palette = "Dark2")
26.19 geom_x_margin_point
Package
ggpp (Aphalo 2024)
Description
Margin points can supplement a 2d display with annotations. Margin points can highlight individual values along a margin.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, alpha
, position
, xintercept
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_xsidefunction
Example
require(ggpp)
drop_na(worldbankdata) |>
filter(Code %in% c('AFG', 'AGO', 'BEN', 'BFA', 'BGD', 'BOL', 'BWA')) |>
ggplot(aes(x = Cooking, y = Electricity, colour = Income)) +
geom_point(size = 1.5) +
geom_x_margin_point(xintercept = seq(0, 75, by = 10)) +
labs(title = "", x = "Cooking", y = "Electricity") + scale_color_brewer(palette = "Dark2") + scale_fill_brewer(palette = "Dark2")
26.20 geom_xsidefunction
Package
ggside (Landis 2024)
Description
The xside and yside variants of geom_function.
Understandable aesthetics
required aesthetics
x
optional aesthetics
color
, alpha
, position
See also
See also
geom_xmax, geom_xmin, geom_x_median, geom_x_mean, geom_x_mean_label, geom_x_percentile, geom_xy_means, geom_x_line, geom_xdiff, geom_x1sd, geom_xydiffsmean, geom_xsidebar, geom_xsidedensity, geom_xsidefreqpoly, geom_xsidehistogram, geom_xsidepoint, geom_xsideboxplot, geom_x_margin_arrow, geom_x_margin_point
Example
require(ggpp)
drop_na(worldbankdata) |>
ggplot(aes(x = Cooking, y = Electricity, colour = Income)) +
geom_point() +
geom_xsidedensity(fill = "#d95f02", alpha = .3) + scale_color_brewer(palette = "Dark2") + scale_fill_brewer(palette = "Dark2")