Reputation: 51
Numbers are top justified with parentheses in geom_label_repel()
(Example with code below). The same behavior occurs when using geom_label()
. How can I get the numbers in the labels to be in the center of the parenthesis?
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()
Upvotes: 3
Views: 49
Reputation: 79194
Update after clarification (removed first answer):
According to this answer Fonts not available in R after importing. We could set the Graphic Device for RStudio to AGG:
Tools > Global options > General > Graphics > Backend: AGG
library(ggrepel)
library(tidyverse)
ggplot(df_cars,aes(mpg,hp))+
geom_point()+
ggrepel::geom_label_repel(aes(label = CarCyl))+
theme_bw()
Upvotes: 3