不知道要的是什么效果,稍微修改一下代码,类似这样吧
ggplot(diamonds,aes(x=price, fill=color)) +
geom_histogram(aes(y=..density..),binwidth=250) +
theme(legend.position="none")
ggplot(diamonds,aes(x=carat,colour=color)) +
geom_histogram(aes(y =..density..),binwidth=0.05,fill="black") +
theme(legend.position = "none")