【问题标题】:Fully Left-Justify When Using atop()使用 atop() 时完全左对齐
【发布时间】:2019-10-20 07:32:21
【问题描述】:

如何在使用atop() 时将文本完全左对齐?

library(tidyverse)

mtcars %>%
  mutate(cyl = str_c("atop(bold(", cyl, "~long~text~on~the~top),(shorttext))")) %>% 
  ggplot(aes(hp, wt)) +
  geom_line() +
  facet_wrap(~cyl, labeller = label_parsed) +
  theme(strip.text.x = element_text(hjust = 0))

【问题讨论】:

  • str_c("atop(bold(", cyl, "),(X))")?
  • 这更接近了,但并不能完全解决问题,我将更新我的示例

标签: r ggplot2 plotmath


【解决方案1】:

现在我肯定会使用出色的 ggtext 包来回答这个问题

library(tidyverse)
library(ggtext)

mtcars %>%
  mutate(cyl = str_c("**", cyl, " long text on the top**<br>(shorttext)")) %>% 
  ggplot(aes(hp, wt)) +
  geom_line() +
  facet_wrap(~cyl) +
  theme(strip.text.x = element_markdown(hjust = 0))

reprex package (v0.3.0) 于 2021-01-03 创建

【讨论】:

    猜你喜欢
    • 2017-05-06
    • 1970-01-01
    • 1970-01-01
    • 2014-10-03
    • 2016-10-02
    • 1970-01-01
    • 1970-01-01
    • 2020-12-06
    • 1970-01-01
    相关资源
    最近更新 更多