-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")
我在做什麼錯了?我該怎麼做呢?
您的建議將不勝感激。