我要創建我的曼哈頓陰謀使用這種編程:GGPLOT2 - R:把不同的顏色對我集團在曼哈頓情節
ggplot(subset(data1), aes(CHR, P),group=CHR) +
geom_point(pos = position_jitter(w = 0.45, h = 0.45),
aes(colour =(CHR)))+
scale_x_discrete(limits=c(1:27)) +
theme(legend.position="none")+ ylab("Bayes Factor") +
geom_hline(yintercept=20,colour="red", alpha=I(1/3)) +
geom_hline(yintercept=150,colour="red", alpha=I(3/3))
但是,在這種情況下,每個組(如CHR)有藍色的水平。 但我希望每個組(每個CHR - 27)都有一種顏色。
我嘗試了一些功能,但並沒有改變顏色:
+ scale_fill_manual(name = "Values", values=setNames(colors, 1:8))
或
+ scale_fill_brewer(palette = "Set1")
或
+ scale_colour_brewer(palette = "Set1")
或
+ scale_colour_brewer(breaks=c("1","2","3","4","5","6","7","8","9","10","11",
"12","13","14","15","16","17","18","19","20","21","22","23","24","25","26",
"27"), palette = "Set1")
或
+ d+scale_colour_brewer(breaks=c("1","2","3","4","5","6","7","8","9","10","11",
"12","13","14","15","16","17","18","19","20","21","22","23","24","25","26",
values = c("#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00",
"#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00","#E69F00",
"#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00","#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00","#E69F00", "#56B4E9", "#009E73"))
也許嘗試把'組= CHR'內'AES(...)在第一線'這樣記載:'ggplot(子集(數據1),AES(CHR ,P,group = CHR))+' – sinQueso
會更容易回答是你提供了足夠的數據(使用'dput')使你的問題可以重現 –
@sinQueso我試過了,但是隻有這個沒有改變。正如馮的回答,這個問題是列分類。但是,謝謝。 –