I am trying to change some of the font style in point labels while leaving other parts unchanged using ggplot. For example, in the code below I would like the word "Italic" in the label to be italicized and the word "red" to be the color red.
For my specific example I dont know how many points will be in the dataframe.
This also has to eventually run in Power BI so some packages, like ggtext, might not work.
library(ggrepel)
library(ggplot2)
df<- mtcars
funlab <- function(y){
paste("Italic","\n","Normal", "red", y)
}
df$label <- mapply(funlab,df$mpg)
ggplot(data =df)+geom_point(data = df, aes(x= wt, y = disp)) +
geom_label_repel(data = df, aes(x= wt, y = disp), label= df$label )