私はWes Anderson library of palettesを使ってグラフを作成しています。ここで、ダミーデータは次のとおりです。すでに定義されているパレットで色を2回使う方法は?
library(ggplot2)
library(wesanderson)
p5<-ggplot(data=df, aes(x=Question, y=n)) +
geom_bar(aes(fill = Agree.Disagree),stat="identity") +
theme_minimal() +
ggtitle("Questions about values and attitudes") +
labs(x = "",y = "n") +
scale_fill_manual(values = wes_palette("GrandBudapest2")) +
geom_text(aes(label=Percent), vjust=2, colour="white") +
coord_flip()
p5
は明らかにこれが機能していません。
structure(list(Question = structure(c(1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L), .Label = c("One", "Two"), class = "factor"),
Agree.Disagree = structure(c(6L, 6L, 2L, 2L, 4L, 4L, 1L,
1L, 5L, 5L, 3L, 3L), .Label = c("Agree", "Disagree", "DK",
"Neither", "Strongly Agree", "Strongly Disagree"), class = "factor"),
n = c(10, 20, 50, 60, 25, 30, 45, 50, 80, 20, 15, 10), Percent = c(4,
11, 22, 32, 11, 16, 20, 26, 36, 11, 7, 5)), .Names = c("Question",
"Agree.Disagree", "n", "Percent"), row.names = c(NA, -12L), class =
"data.frame")
ここでグラフのコードがあります。私は以前は簡単な回避策を知っていましたが、今は何かを覚えていません。何か案は?
はまさに、私はこれは私が前にやったことだと思います。 –