by Edgar Ruiz 原文链接
ggplot图形的增强包ggforce,实现强调部分数据的功能。
library(tidyverse)
library(ggforce)
library(nycflights13)
p <- airports %>%
filter(lon < 0, tzone != "\\N") %>%
ggplot(aes(lon, lat, color = tzone)) +
geom_point(show.legend = FALSE)
给图上添各种圈
p + geom_mark_rect()
image.png
p +
geom_mark_rect(aes(label = tzone))
image.png
p +
geom_mark_rect(aes(label = tzone), show.legend = FALSE) +
theme_void()
image.png
p +
geom_mark_hull(aes(label = tzone)) +
theme_void()
image.png
p +
geom_mark_hull(aes(label = tzone, fill = tzone), show.legend = FALSE) +
theme_void()
image.png
p +
geom_mark_hull(aes(label = tzone, fill = tzone), show.legend = FALSE, expand = unit(3, "mm")) +
theme_void()
image.png
p +
geom_mark_hull(aes(label = tzone, fill = tzone), show.legend = FALSE, expand = unit(3, "mm")) +
theme_no_axes()
image.png
p +
geom_mark_hull(aes(label = tzone, fill = tzone), show.legend = FALSE, expand = unit(3, "mm")) +
theme_no_axes() +
facet_zoom(x = tzone == "America/Los_Angeles")
image.png
网友评论