2016-08-10 5 views
0

Ich habe ein Streudiagramm von 100k ++ Punkten und ich möchte die Farbpunkte (Break-Werte 1 und 2, die "grün" und Break-Wert 20, die "rot" ist) um mehr als die "cornsilk1" -Punkte hervorzuheben (Pausenwerte 3 bis 19). Ich habe den folgenden Code ausprobiert, aber kein Glück.Ändern Alpha-Wert für bestimmte Pause-Werte in Ggplot geom_point

Jede Hilfe wäre willkommen. Vielen Dank

p.s. Bitte entschuldigen Sie meinen Jugendcode. Ich bin sicher, dass es eine Möglichkeit, effektiver Weg, dies zu tun ...

plotIA<-ggplot(plotintaobs,aes(x=SD13009PB,y=SD13009PB2,colour=quartile))+geom_point()+labs(x="Phillips Observeration 1", y="Phillips Observation 2") + ggtitle("Intra-observer Variation") + mytheme 


plotIA+ scale_color_manual(breaks = c("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"), 
values=c("green","green", "cornsilk1", "cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","cornsilk1","red")) 

plotIA+scale_alpha_manual(values=c(1,1,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1)) 
+0

Könnten Sie bitte posten 'dput (plotintaobs)'? juvenile ist OK, aber Sie sind aufgefordert, reproduzierbare Beispiele zu veröffentlichen: http://StackOverflow.com/Help/Mcve –

+0

Wahrscheinlich 'Aes (..., Alpha = Quartil)' löst Ihr Problem. – cuttlefish44

+0

Leider ist dput (plotintaobs) zu groß zum Posten. Aber aes (..., Alpha = Quartil) hat funktioniert. Ich danke dir sehr –

Antwort

0

Eine Strategie ist cut zu verwenden, um die Quartile in in dem drei Gruppen aufgeteilt. Dann können Sie scale_colour_manual verwenden

# some fake data 
plotintaobs <- data.frame(SD13009PB = rnorm(20), SD13009PB2 = rnorm(20), quartile = 1:20) 

#cut quartile 
plotintaobs$q2 <- cut(plotintaobs$quartile, breaks = c(0, 2, 19, 20), labels = c("low", "mid", "high")) 

#plot 
plotIA <- ggplot(plotintaobs, aes(x = SD13009PB, y = SD13009PB2, colour = q2, alpha = q2)) + 
    geom_point() + 
    scale_colour_manual(values = c("green", "cornsilk1","red")) + 
    scale_alpha_manual(values = c(1, 0.8, 1)) 

plotIA 
Verwandte Themen