【发布时间】:2017-06-03 19:46:20
【问题描述】:
我编写了代码,使用 ggplot 为两个类绘制某个数值变量的密度图。但我无法处理传奇的外观。我的代码如下:
mu <- ddply(german, "Class", summarise, grp.mean=mean(Credit_amount))
ggplot(german, aes(x=Credit_amount, fill=as.factor(Class))) +
geom_histogram(aes(y=..density..), position="identity", alpha=0.3)+
geom_density(alpha=0.6)+
geom_vline(data=mu, aes(xintercept=grp.mean, color= as.factor(Class)),
size = 2, alpha = 0.6)+
labs(title="Credit_amount for the Two Classes (Good and Bad Creditors",x="Credit_amount", y = "Density") +
scale_fill_manual(limits=c("1", "0"), labels = c("Bad Creditors", "Good Creditors"), values = c("blue", "red"))
+ labs(fill="Class of Customers")
我做错了什么?我应该怎么做?
您的建议将不胜感激。
【问题讨论】: