Status Quo
library(tidyverse)
gapminder_2002 <- gapminder::gapminder |> filter(year == 2002)
theme_set(
)
p <- ggplot(data = gapminder_2002) +
aes(x = gdpPercap/1000,
y = lifeExp) +
geom_point() +
scale_x_log10()
code_eval_label <- function(x){ eval(parse(text = x)) + labs(subtitle = x) }
code008 <-
'p +
ggforce::geom_voronoi_tile(normalize = T,
color = "darkgrey",
alpha = .5) +
aes(fill = continent, group = 1)
'
code000 <- 'p'
code001 <- 'p + geom_hex(alpha = .5)'
code002 <- 'p + geom_hex(bins = 10, alpha = .5, color = "white")'
code003 <- 'p + ggforce::geom_mark_rect() +
aes(fill = continent, color = continent)'
code004 <- 'p + geom_smooth()'
code005 <- 'p + geom_smooth(method = lm)'
code006 <- 'p + geom_quantile()'
code007 <- 'p + geom_rug()'
out <- code000 |> code_eval_label(); out; out -> p_base_plot

out <- code008 |> code_eval_label(); out; out -> p_geom_voronoi_tile

out <- code001 |> code_eval_label(); out; out -> p_geom_hex

out <- code002 |> code_eval_label(); out; out -> p_geom_hex_bins_10

out <- code003 |> code_eval_label(); out; out -> p_geom_mark_rect

out <- code004 |> code_eval_label(); out; out -> p_geom_smooth
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

out <- code005 |> code_eval_label(); out; out -> p_geom_smooth_lm
## `geom_smooth()` using formula = 'y ~ x'

out <- code006 |> code_eval_label(); out; out -> p_geom_quantile
## Smoothing formula not specified. Using: y ~ x

out <- code007 |> code_eval_label(); out; out -> p_geom_rug

library(patchwork)
individual_plots_theme <- theme_void(base_family = "mono", base_size = 30) +
theme(palette.fill.continuous = "viridis") +
theme(plot.background = element_rect(color = "black", linewidth = .2),
plot.margin = margin(8,8,8,8),
panel.background = element_rect(fill = "grey95"))
p_base_plot +
p_geom_smooth +
p_geom_smooth_lm +
p_geom_rug +
p_geom_quantile +
p_geom_voronoi_tile +
p_geom_hex +
p_geom_hex_bins_10 +
p_geom_mark_rect +
plot_annotation(title = "continuous x, continuous y\n", subtitle = "p <- ggplot(data = gapminder_2002) +
aes(x = gdpPercap/1000,
y = lifeExp) +
geom_point()\n") &
individual_plots_theme
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## Smoothing formula not specified. Using: y ~ x

d <- diamonds |>
ggplot() +
aes(carat, price) +
geom_point() +
scale_x_log10() +
scale_y_log10() +
scale_color_viridis_c()
d + ggpointdensity::geom_pointdensity()
## geom_pointdensity() using method='kde2d' due to large number of points (>20k). You may override this by setting method='neighbors'.

i <- ggplot(economics) + aes(date, unemploy) + geom_point(alpha = .2)
'i' |> code_eval_label() +
'i + geom_area()' |> code_eval_label() +
'i + geom_line()' |> code_eval_label() +
'i + geom_step(direction = "hv") + economics |> slice(1:20)' |> code_eval_label() &
individual_plots_theme
