这个问题已经被问和回答了几次-最近的here次-但都有几年了,涉及For-循环和grid
,而且有点老生常谈.我想知道有没有什么新的方法来改变我的条带文本的 colored颜色 以匹配标题文本,最好是在ggploy中.
library(ggplot2)
library(ggtext)
facet_colors <- c("#43A047","#8A2BE2", "#007ACC")
iris |>
pivot_longer(-Species) |>
ggplot(aes(x = name,
y = value,
# group = Species,
fill = Species)) +
geom_boxplot() +
scale_fill_manual(values = facet_colors) +
labs(title ="Feature Comparison of <span style = 'color: #43A047;'>Setosa</span>,
<span style = 'color: #8A2BE2;'>Versicolor</span> and
<span style = 'color: #007ACC;'>Virginica</span>") +
facet_wrap(~Species) +
theme_minimal() +
theme(plot.title = element_markdown())