我正在尝试创建钻石价格直方图,显示切割钻石的比例。这就是我所得到的:
ggplot(aes(x = price), data = diamonds_df) +
geom_histogram(binwidth = 0.1, fill = "white", colour = "black") +
facet_wrap(~color, scales = "free_y") +
scale_x_log10() +
ylab("Total Count") +
xlab("Diamond Price") +
ggtitle("Distribution of diamond prices for different diamond colours and cuts")
我试过使用
color = cut
而且还
fill = cut
在美学包装中,但无济于事。
发布于 2016-04-11 20:31:03
这段代码给出了我想要的图,但它看起来相当混乱。
ggplot(diamonds_df, aes(price, fill=cut)) +
geom_bar(width = 0.05) +
facet_wrap(~color, scales = "free_y") +
scale_x_log10() +
ylab("Total Count") +
xlab("Diamond Price") +
ggtitle("Distribution of diamond prices for different diamond colours and cuts")
https://stackoverflow.com/questions/36548579
复制相似问题