[1] 18.85455
[1] 4.342182
In The Visual Display of Quantitative Information (1983), Edward Tufte says that graphical displays should:
p1 <- ggplot(data, aes(x = Height)) +
geom_density() +
labs(y = "Density", x = "Height (Inches)", title = "Density Plot") +
theme_classic(base_size = 18)
p2 <- ggplot(data, aes(x = Height)) +
geom_histogram(binwidth = 1) +
labs(y = "Count", x = "Height (Inches)", title = "Histogram") +
theme_classic(base_size = 18)
gridExtra::grid.arrange(p1, p2, nrow = 1)p1 <- ggplot(d, aes(x = Height, y = Weight)) +
geom_point(size = 2, alpha = 0.2) +
labs(y = "Weight (Pounds)", x = "Height (Inches)", title = "Scatter Plot\n") +
theme_classic(base_size = 16) +
ylim(145, 155)
p2 <- ggplot(d, aes(x = Height, y = Weight)) +
geom_smooth(size = 2, method = "loess") +
labs(y = "Weight (Pounds)", x = "Height (Inches)", title = "Smooth Plot\n") +
theme_classic(base_size = 16) +
ylim(145, 155)
p3 <- ggplot(d, aes(x = Height, y = Weight)) +
geom_point(size = 2, alpha = 0.3) +
geom_smooth(size = 2, method = "loess") +
labs(y = "Weight (Pounds)", x = "Height (Inches)", title = "Scatter Plot with\nSmooth Line") +
theme_classic(base_size = 16) +
ylim(145, 155)
gridExtra::grid.arrange(p1, p2, p3, nrow = 1)p1 <- ggplot(d, aes(x = name, y = value)) +
geom_boxplot() +
labs(y = "Height (Inches)", x = "", title = "Box Plot") +
theme_classic(base_size = 18)
p2 <- ggplot(d, aes(x = name, y = value)) +
geom_violin() +
labs(y = "Height (Inches)", x = "", title = "Violin Plot") +
theme_classic(base_size = 18)
p3 <- ggplot(d, aes(x = name, y = value)) +
geom_violin() +
geom_boxplot(width = 0.5) +
labs(y = "Height (Inches)", x = "", title = "Box and Violin Plot") +
theme_classic(base_size = 18)
gridExtra::grid.arrange(p1, p2, p3, nrow = 1)ggplot(p, aes(x = Height, y = p, fill = Weight, label = text)) +
geom_col(size = 8, position = position_dodge()) +
geom_text(position = position_dodge(width = 0.9), vjust = -0.5) +
labs(y = "Proportion", x = "Height (Inches)", color = "Weight (Pounds)", title = "Proportion Plot") +
theme_classic(base_size = 20)