2017-02-10 2 views
6

Mit diesem SkriptAlign zweizeilige Legende Titel nach links mit Ausdruck()

df <- data.frame(x = 1:5, y = 1:5, color = letters[1:5]) 
ggplot(df, aes(x, y, fill = color)) + 
    geom_point(size = 4, pch = 21) + 
    guides(fill = guide_legend(
    title = expression(atop(Median~Nitrate-Nitrogen~(NO[3]^{textstyle("-")}-N), ".\n Concentration"~(mg~L^{textstyle("-")}))))) 

Ich habe diese Figur

enter image description here

Irgendwelche Vorschläge, wie die zweite Zeile der Legende Titel ausrichten nach links?

+0

Mögliches Duplikat http://stackoverflow.com/questions/13223846/ggplot2-two-line-label-with -ausdruck – akrun

+1

@akrun Ich glaube nicht. – aelwan

+1

Okay, gut, es ist nur ein Link und ich habe es nicht als dupe markiert – akrun

Antwort

5

schnelle und hässliche Antwort, aber es macht den Job, bis jemand besser posten ...

ggplot(df, aes(x, y, fill = color)) + 
    geom_point(size = 4, pch = 21) + 
    guides(fill = guide_legend(
    title = expression(atop(Median~Nitrate-Nitrogen~(NO[3]^{textstyle("-")}-N), "Concentration"~(mg~L^{textstyle("-")})~phantom (1000000)~phantom (1000000))))) 
+0

Danke für Ihre Zeit und Hilfe – aelwan