library(ggplot2)
library(distributional)
# ggplot
b <- ggplot(mtcars, aes(wt, mpg)) +
geom_point()
# ggdibbler
a <- ggplot(uncertain_mtcars, aes(wt, mpg)) +
geom_point_sample(seed=77, alpha=0.5)
df <- data.frame(x1 = 2.62, x2 = 3.57,
y1 = 21.0, y2 = 15.0)
uncertain_df <- data.frame(x1 = dist_normal(2.62, 0.1),
x2 = dist_normal(3.57,0.1),
y1 = dist_normal(21.0, 0.1),
y2 = dist_normal(15.0,0.1))
# ggplot
b +
geom_curve(aes(x = x1, y = y1, xend = x2, yend = y2, colour = "curve"), data = df) +
geom_segment(aes(x = x1, y = y1, xend = x2, yend = y2, colour = "segment"), data = df)
# ggdibbler
a +
geom_curve_sample(aes(x = x1, y = y1, xend = x2, yend = y2, colour = "curve"),
data = uncertain_df, seed=77, alpha=0.5) +
geom_segment_sample(aes(x = x1, y = y1, xend = x2, yend = y2, colour = "segment"),
data = uncertain_df, seed=77, alpha=0.5)
Run the code above in your browser using DataLab