0
私はグラフをプロットしていますが、私が割り当てるファクタレベルの順序と関数scale_fill_manual()はggplotによって無視されます。ggplotでファクタレベルとscale_fill_manual()引数が無視されるR
データセットは、リポジトリを学ぶUCIマシンで見つけることができますドイツ語クレジットデータセットで、コードは以下の通りです:
german_fct_train$Status_of_existing_account <- factor(german_fct_train$Status_of_existing_account ,
levels = c("No_Account" , "less_than_0" , "between_0_and_200" , "greater_equal_to_200"))
german_fct_train$Class <- factor(german_fct_train$Class, levels = c("1" , "0"))
ggplot(german_fct_train, aes(F_Credit_history, F_Status_of_existing_account)) +
geom_jitter(aes(color = Class), size = 3, alpha = 0.5) + theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) + ggtitle("Status of existing checking account
and Credit History by Class") +
xlab("Credit History") + ylab("Status of existing account") +
labs(fill="Class") +
scale_fill_manual(limits= c("1", "0"), labels = c("Bad Customers" , "Good Customers"), values = c("red", 'blue'))
あなたのアドバイスが理解されるであろう。
代わりに 'scale_colour_manual'を試してみてください – bouncyball