【发布时间】:2017-11-29 17:28:21
【问题描述】:
我正在尝试将形状(和填充颜色)插入标题/副标题,但找不到这样做的语法:
library(tidyverse)
D <-diamonds %>% filter(color=="D") %>%sample_frac(0.1)
G <-diamonds %>% filter(color=="G") %>% sample_frac(0.1)
ggplot(D, aes(x=carat, y=price))+
geom_jitter(data=G)+geom_point(shape=6)+
geom_jitter(data=D)+geom_point(shape=22, fill='red')+
labs(title, "This is a title",
subtitle=
"D diamonds (insert shape 22 fill red) and G diamonds (shape 6 color black)",
caption = "what I want is to insert the shape and fill color into the (sub)title")
建议? Annotate 似乎只在情节空间中工作。
【问题讨论】:
-
您能否制作一个图例并将其移动到标题下方的左上角作为解决方法?
标签: r ggplot2 title shape subtitle