[英]ggplot2 column chart with facet_grid
I'm trying to make a R ggplot2
chart with columns grouping one variable, and a facet_grid
to break down by another. 我正在尝试制作一个R
ggplot2
图表,其中的列将一个变量分组,而facet_grid
其分解为另一个变量。 Both ways I've tried have failed: 我尝试过的两种方法都失败了:
1) Setting x
as the facet_grid
variable breaks down by that variable twice: 1)将
x
设置为facet_grid
变量会两次被该变量分解:
ggplot(diamonds, aes(x=cut, y=price, fill=color)) +
geom_bar(position="dodge", stat="identity") +
facet_grid(cut ~ ., scales="free")
2) Dropping x
produces an error: 2)删除
x
会产生错误:
ggplot(diamonds, aes(y=price, fill=color)) +
geom_bar(position="dodge", stat="identity") +
facet_grid(cut ~ ., scales="free")
# Error in exists(name, envir = env, mode = mode):
# argument "env" is missing, with no default
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.