wilkelab / ggtext

Improved text rendering support for ggplot2
https://wilkelab.org/ggtext/
GNU General Public License v2.0
651 stars 37 forks source link

How to italicize a single word in a ggplot title that is passed as a variable to a function? #28

Closed DeFilippis closed 4 years ago

DeFilippis commented 4 years ago

Let's say I have the following function where I pass a dataframe and a variable name:

plot_breaks <- function(data, dv){
 ggplot(data = data, aes(x = date, y = dv)) + 
    geom_line() +
    ggtitle(paste("Time Series of ", dv)) +
    xlab("Date") 
}

I want to italicize the string passed as part of the dv variable. How would I do this in ggtext?

clauswilke commented 4 years ago

This question would be better suited to a general-purpose discussion board, such as stackoverflow.com.