Colorize parts of the title in a plot

前端 未结 3 1407
予麋鹿
予麋鹿 2020-12-14 01:58

Is it possible to colorize parts of the title in a plot?

x = 1:10
y = 1:10
plot(x, y, main=\"title (slope=1)\")

In this plot I\'d like to c

3条回答
  •  无人及你
    2020-12-14 02:12

    A solution for ggplot2 plots using the ggtext package

    library(ggplot2)
    # devtools::install_github("clauswilke/ggtext")
    library(ggtext)
    
    p <- ggplot(mtcars, aes(mpg, wt, colour = cyl)) + 
      geom_point(size = 3)
    
    p + 
      labs(title = "New plot title", 
           subtitle = "A subtitle") +
      theme_classic(base_size = 24) +
      theme(plot.title = element_markdown(lineheight = 1.1),
            plot.subtitle = element_markdown(lineheight = 1.1))
    

    Created on 2019-08-11 by the reprex package (v0.3.0)

提交回复
热议问题