ggplot2标题下划线与粗体输出:2020-12-29
2022-04-15 本文已影响0人
RashidinAbdu
-
下划线的标题:
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