美文网首页
ggplot2标题下划线与粗体输出:2020-12-29

ggplot2标题下划线与粗体输出:2020-12-29

作者: RashidinAbdu | 来源:发表于2022-04-15 08:56 被阅读0次
    • 下划线的标题:

    DF<- data.frame(x = 1:10, y = 1:10)
    ggplot(DF, aes(x = x, y = y)) + geom_point() +
        ggtitle(expression( underline('Hello Rashidin Abdugheni! ')))
    
    image.png
    • 加粗的标题:

    DF<- data.frame(x = 1:10, y = 1:10)
    ggplot(DF, aes(x = x, y = y)) + geom_point() +
        ggtitle(expression( underline('Hello Rashidin Abdugheni! ')))
    
    image.png
    • 加粗并下划线的标题:

    DF<- data.frame(x = 1:10, y = 1:10)
    ggplot(DF, aes(x = x, y = y)) + geom_point() +
        ggtitle(expression(bold(underline('Hello Rashidin Abdugheni! '))))
    
    image.png
    • 斜体标题:

    DF<- data.frame(x = 1:10, y = 1:10)
    ggplot(DF, aes(x = x, y = y)) + geom_point() +
        ggtitle(expression( italic('Hello Rashidin Abdugheni! ')))
    
    image.png
    • 下划线放在中间的标题:

    DF<- data.frame(x = 1:10, y = 1:10)
    ggplot(DF, aes(x = x, y = y)) + geom_point() +
        ggtitle(expression( underline('Hello Rashidin Abdugheni! ')))+theme(plot.title = element_text(hjust = 0.5))     # Center ggplot title
    
    image.png
    • 下划线放在右侧的标题

    DF<- data.frame(x = 1:10, y = 1:10)
    ggplot(DF, aes(x = x, y = y)) + geom_point() +
        ggtitle(expression( italic('Hello Rashidin Abdugheni! ')))+
        theme(plot.title = element_text(hjust = 1))       # Align title on right side
    
    image.png
    • 垂直距离的调整:

    DF<- data.frame(x = 1:10, y = 1:10)
    ggplot(DF, aes(x = x, y = y)) + geom_point() +
        ggtitle(expression( underline('Hello Rashidin Abdugheni! ')))+
        theme(plot.title = element_text(vjust = 3))       # Change vertical position
    
    image.png
    • 标题置于图内:

    DF<- data.frame(x = 1:10, y = 1:10)
    ggplot(DF, aes(x = x, y = y)) + geom_point() +
        ggtitle(expression( italic('Hello Rashidin Abdugheni! ')))+
        theme(plot.title = element_text(vjust = - 10))    # Change position downwards
    
    image.png
    • 标题置于图下(不太合适!):

    DF<- data.frame(x = 1:10, y = 1:10)
    ggplot(DF, aes(x = x, y = y)) + geom_point() +
        ggtitle(expression( underline('Hello Rashidin Abdugheni! ')))+
        theme(plot.title = element_text(vjust = -153,hjust = 0.5))       # Change vertical position
    
    image.png
    • 标题置于图下:

    DF<- data.frame(x = 1:10, y = 1:10)
    ggplot(DF, aes(x = x, y = y)) + geom_point() +labs(title = "Hello Rashidin",tag = "Figure 1: This is a test note") +coord_cartesian(clip = "off") +theme(plot.title = element_text(hjust = 0.5),plot.margin = margin(t = 10, r = 10, b = 40, l = 10),plot.tag.position = c(0.2, -0.1))
    
    
    image.png
    • 将tag置于中间位置:

    DF<- data.frame(x = 1:10, y = 1:10)
    ggplot(DF, aes(x = x, y = y)) + geom_point() +labs(title = "Hello Rashidin",tag = "Figure 1: This is a test note") +coord_cartesian(clip = "off") +theme(plot.title = element_text(hjust = 0.5),plot.margin = margin(t = 10, r = 10, b = 40, l = 10),plot.tag.position = c(0.5, -0.1))
    
    image.png

    相关文章

      网友评论

          本文标题:ggplot2标题下划线与粗体输出:2020-12-29

          本文链接:https://www.haomeiwen.com/subject/cqaqoktx.html