我使用R包ggtext来"plot align“(最大左对齐)我的标题和副标题。我还想使用这些ggtext方法来“对齐”我的标题。
library(tidyverse)
library(ggtext)
ggplot(mpg, aes(cty, hwy)) +
geom_point() +
theme(plot.title.position = "plot",
plot.caption.position = "plot",
plot.title = element_markdown(),
plot.subtitle = element_markdown(),
plot.caption = element_markdown()) +
labs(title = "This is the title.",
subtitle = "This is the subtitile.",
caption = "This is the caption.")你可能会注意到标题是右对齐的,而标题和副标题是“绘图对齐”的。

如何“打印对齐”我的标题?
发布于 2020-11-07 05:08:54
这是可行的。基于@Ben评论。
library(tidyverse)
library(ggtext)
ggplot(mpg, aes(cty, hwy)) +
geom_point() +
theme(plot.title.position = "plot",
plot.caption.position = "plot",
plot.title = element_markdown(),
plot.subtitle = element_markdown(),
plot.caption = element_markdown(hjust = 0)) +
labs(title = "This is the title.",
subtitle = "This is the subtitile.",
caption = "This is the caption.")发布于 2021-04-04 05:58:57
为了其他人的利益,您可以通过以下方式在ggplot2中左对齐标题:
library(ggplot2)
ggplot(mpg, aes(cty, hwy)) +
geom_point() +
theme(plot.caption = element_text(hjust = 0)) + # set the left align here
labs(title = "This is the title.",
subtitle = "This is the subtitile.",
caption = "This is the caption.")

https://stackoverflow.com/questions/64701500
复制相似问题