我非常喜欢刻面图标题的风格:
require(ggplot2)
df <- data.frame(x = rnorm(1E3), labels = as.factor(c(rep("plot1",500), rep("plot2",500))));
ggplot(df, aes(x=x) ) + geom_histogram() +facet_wrap(~labels)
我想以类似的方式格式化其他情节的标题。当我将 ggtitle() 添加到图中时,我得到以下信息:
ggplot(df, aes(x=x) ) + geom_histogram() +ggtitle('plot1 and plot2')
如何将 ggtitle 标题格式化为看起来像 facet_wrap 标题?
谢谢!
最佳答案
如果您希望事情看起来像 strip 标签,您可以为您的标题创建一个新列,其中包含一个组并使用该变量进行分面。
基本上使用带有假变量的 facet 来获得您喜欢的外观。
df$overall = "plot1 and plot2"
ggplot(df, aes(x=x) ) +
geom_histogram() +
facet_wrap(~overall)
关于r - 非分面图中的分面式标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44954361/