使用 R ggplot2 库,我生成了一个 facet_grid 图,我想在所有图的右侧放置一个图例 - 不是每个单独的图,而是一个适用于所有图的图例
g = ggplot(pd2, aes(x = p/1000, y=c/1000 )) +
geom_point(alpha=.1, colour="red") +
geom_smooth(method=lm) +
xlab("Ave P") +
ylab("Ave C)") +
labs(title = "Comparison ") +
theme(plot.title = element_text(face="bold",
size=14, colour="black", hjust = 0.5)) +
theme(axis.title = element_text(face="bold", size=12, colour="blue")) +
facet_grid(code ~ TheState) +
theme(strip.text.y = element_text(colour = "purple", angle = 0,
size = 9, hjust = 0.5, vjust = 0.5))
我想要做的是将图例向右转 90 度 - 因为我希望图例引用very_long_code 而不仅仅是“代码”。我尝试了各种传说、主题和指南的变体。直觉上,我想说,
legend(text, angle=90, very_long_code, color="purple")
下一步将不使用单一颜色,而是为每种颜色使用与条带中的颜色相对应的不同颜色。