geom_text()
geom_text(
mapping = NULL,
data = NULL,
stat = “identity”,
position = “identity”,
…,
parse = FALSE,
nudge_x = 0,
nudge_y = 0,
check_overlap = FALSE,
hjust=‘center’,
vjust=‘center’
angel=0
size=4
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE)
mapping = NULL,
data = NULL,
如果在前面有对应的ggplot(data,aes(x,y)),那么geom_text(mapping,data)则继承该参数,否则需用户自己提供指定。
stat = “identity”,
该图层数据的统计变换,为字符串
position
位置调整,字符串
nudge_x = 0,
nudge_y = 0,
水平或者垂直调整text与数据点的距离,避免遮挡
ggplot(df, aes(x, y)) +geom_point()+geom_text(aes(label = text),nudge_x=0,nudge_y=0)
ggplot(df, aes(x, y)) +geom_point()+geom_text(aes(label = text),nudge_x=0.1,nudge_y=0.1)