2017-02-10 44 views
6

使用這個腳本對齊兩個線圖例標題的左邊表達式()

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("-")}))))) 

我得到這個數字

enter image description here

任何建議如何使圖例標題的第二行往左邊?

+0

http://stackoverflow.com/questions/13223846/ggplot2-two-line-label-with的可能的複製 - 表達 – akrun

+1

@akrun 我不這麼認爲。 – aelwan

+1

好的,很好,它只是一個鏈接,我沒有將它標記爲笨蛋 – akrun

回答

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), "Concentration"~(mg~L^{textstyle("-")})~phantom (1000000)~phantom (1000000))))) 
+0

感謝您的時間和幫助 – aelwan