[英]ggplot2 line between title and subtitle
One possible solution is to manually trace a segment using geom_segment
while setting clip = "off"
on coord_cartesian
:一种可能的解决方案是在
coord_cartesian
上设置clip = "off"
时使用geom_segment
手动跟踪段:
df <- data.frame(x = 1:10,
y = 2:11)
ggplot(df, aes(x = x, y = y))+
geom_point()+
labs(title = "Main Title", subtitle = "Subtitle")+
coord_cartesian(clip ="off")+
geom_segment(x =0.5, xend = 2.5, y = 12.1, yend = 12.1)
You will have to adapt the position based on data you are going to plot but it is one possible solution您将不得不根据您要转到 plot 的数据来调整 position,但这是一种可能的解决方案
Another option simply to underline your Main title另一个选项只是在您的主标题下划线
library(ggplot2)
df <- data.frame(x = 1:10,
y = 2:11)
ggplot(df, aes(x = x, y = y)) +
geom_point() +
labs(title = ~ underline("Main Title"), subtitle = "Subtitle")
related thread: How to underline text in a plot title or label?相关主题: 如何在 plot 标题或 label 中为文本添加下划线? (ggplot2)
(ggplot2)
You could also play around in order to achieve a solution as suggested by user Stephane Laurent in their comment, pasting some empty spaces after a line break您也可以按照用户 Stephane Laurent 在评论中的建议来实现解决方案,在换行符后粘贴一些空格
Created on 2020-04-22 by the reprex package (v0.3.0)由代表 package (v0.3.0) 于 2020 年 4 月 22 日创建
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.