gpt4 book ai didi

r - 在绘图标题中混合不同的字体大小/面孔

转载 作者:行者123 更新时间:2023-12-05 01:15:51 32 4
gpt4 key购买 nike

使用下面的代码在 R 中生成热图。效果很好。第一部分是我用来为 map 着色的指标。我的问题是如何让标题如下所示。我知道有人会将第一行放在以 caption = Paste ("Source...") 开头的部分中,但是如何让第一行更大并且粗体字体让我无法理解。

Current Result

 map50<- merge(us50, pop1)

breaks <- seq(-.01, .05, by = .01)
map50$c1<- cut(map50$growth, breaks, label=c("-1% to 0%", "0% to 1%", "1%
to 2%", "2% to 3%", "3% to 4%","4% to 5%"))


library(ggplot2)
b= ggplot(data= map50, aes(x=long, y=lat, group=group))
d= b+geom_polygon(aes(fill=c1),
colour=alpha("black"),size=.05)+scale_fill_brewer(palette="YlOrRd",name="y/y
growth rates")+coord_equal()
d= d+labs(x = NULL, y = NULL, fill = NULL,
title = "Average Employment Growth By State Q3 2018",
subtitle = "For Private, All Industries",
caption = paste("Source: BLS Quarterly Census of Employment and
Wages\nProduced By: @NVlabormarket"))
d= d+theme_void()
d=d+theme(text = element_text(family = "NimbusSan", size = 10),
plot.title = element_text(size = 20, face = "bold"),
plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"),
panel.border = element_rect(fill = NA, colour = "#cccccc"),
legend.text = element_text(size = 8),
legend.position=c(.93, 0.2))
ggsave("Q32018EmploymentGrowthHeat-YlOrRdu.pdf")

最佳答案

您可以使用 caption 参数绘制第一行标题(粗线),使用 labs 函数中的 tag 参数绘制第二行。接下来,您必须使用 plot.tag.position 手动指定标签位置。

library(ggplot2)
ggplot(mtcars, aes(cyl, mpg)) +
geom_point() +
labs(caption = "Source: BLS Quarterly Census of Employment and Wages",
tag = "Produced By: @NVlabormarket") +
theme(plot.caption = element_text(vjust = 4, size = 9, face = "bold"),
plot.tag = element_text(size = 9),
plot.tag.position = c(0.89, 0))

enter image description here

关于r - 在绘图标题中混合不同的字体大小/面孔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55150482/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com