我想使用facet_grid:
在彼此的顶部绘制一些条形图library(ggplot2)
df <- group_by(mpg, manufacturer) %>%
summarise(cty = mean(cty), hwy = mean(hwy)) %>%
ungroup()
df <- melt(df, id.vars = "manufacturer")
ggplot() +
geom_bar(data =df, aes(x = variable, y = value), stat = "identity") +
facet_grid(manufacturer ~ ., switch = "y")
我使用switch
的{{1}}参数让刻面标签显示在y轴上,而不是显示在每个刻面的顶部。问题是刻面标签是垂直绘制的,因此会被裁剪。有没有办法水平绘制facet -labels?到目前为止,我发现的所有问题只与旋转x轴标签有关,而不是与刻面标签有关。
答案 0 :(得分:45)
您只需添加theme()并在strip.text.y
中指定角度 * This include file attempts to categorize possible error
* exit statuses for system programs, notably delivermail
* and the Berkeley network.
* Error numbers begin at EX__BASE [64] to reduce the possibility of
* clashing with other exit statuses that random programs may
* already return.