2016-09-26 7 views
0

Ich habe Probleme mit ggplot unter Verwendung von Koordinatentransformationen mit einer log10-Skalierung. Ich möchte meine Daten auf einer log10-Achse darstellen, aber ohne die Daten selbst zu skalieren. Dies funktioniert mit sqrt, aber bei Verwendung von Koordinaten einer Log-Achse erscheinen keine Balken. Kannst du mir bitte sagen, was ich vermisse?ggplot Ausweichenleiste wird nicht angezeigt, wenn Log-Koordinatentransformation durchgeführt wird

d <- data.frame(x=factor(c(1,1,2,2)), y=c(1,2,3,4), fill=factor(c(1,2,3,4))) 

#sqrt axis tranformaion works 
ggplot(d, aes(x = x, fill = fill)) + 
    geom_bar(aes(y = y), stat = "identity", position = "dodge") + 
    coord_trans(y = "sqrt") 

#log10 axis tranformaion doesn't work 
ggplot(d, aes(x = x, fill = fill)) + 
    geom_bar(aes(y = y), stat = "identity", position = "dodge") + 
    coord_trans(y = "log10") 

#log10 axis tranformaion works with points rather than bars 
ggplot(d, aes(x = x, fill = fill)) + 
    geom_point(aes(y = y), stat = "identity") + 
    coord_trans(y = "log10") 

Antwort

0

Versuchen Sie es mit der scale_y_log10 Funktion:

ggplot(d, aes(x = x, fill = fill)) + 
    geom_bar(aes(y = y), stat = "identity", position = "dodge") + 
    scale_y_log10() 
Verwandte Themen