数字顶部对齐,并在
geom_label_repel()
中带有括号(下面的代码示例)。使用 geom_label()
时也会发生相同的行为。如何使标签中的数字位于括号的中心?
library(tidyverse)
df_cars<-
mtcars[2:6,] %>%
mutate(CarName = rownames(.),
CarCyl = paste(CarName, " (",cyl,")",sep = ""))
ggplot(df_cars,aes(mpg,hp))+
geom_point()+
ggrepel::geom_label_repel(aes(label = CarCyl))+
theme_bw()