-1
我已经编写了使用ggplot绘制两个类的某个数值变量的密度图的代码。但我无法处理传奇的外观。我的代码如下:控制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")
我在做什么错了?我该怎么做呢?
您的建议将不胜感激。