2015-11-13 8 views
6

मैं एक ggplot के लिए एक fill legend से रंग रेखा को हटाना चाहता हूँ। मैं आमतौर पर किंवदंती सौंदर्यशास्त्र को संशोधित करने के लिए guide_legend(override.aes = ...) का उपयोग करता हूं - अंक, रेखाएं, अल्फा इत्यादि के लिए बहुत अच्छा काम करता है, लेकिन यह मेरे color सौंदर्यशास्त्र के लिए काम नहीं कर रहा है। मैं क्या गलत कर रहा हूं?मैं किंवदंती में रंग बदलने के लिए override.aes ​​का उपयोग क्यों नहीं कर सकता?

# generate data 
set.seed(47) 
data = data.frame(year = rep(2000:2004, 3), 
        value = runif(15), 
        group = rep(c("A", "B", "C"), each = 5)) 

# create the plot 
p = ggplot(data, aes(x = year, y = value, fill = group)) + 
    geom_area(position = position_fill(), color = "white") + 
    scale_fill_grey() 

# this should modify the fill legend to remove the colored line 
# but the line is still there 
p + guides(fill = guide_legend(override.aes = list(color = NA))) 

enter image description here

उत्तर

8

इस मामलों में जहां colour एक u साथ वर्तनी किया जाना चाहिए में से एक है।

p + guides(fill = guide_legend(override.aes = list(colour = NA))) 

enter image description here

+1

यह देव संस्करण में पहले से ही बदल दिया गया है: u जोड़ना override.aes काम ठीक कर देता है। – joran

+2

"ggplout2" -hadley – rawr

+0

जब मैंने लिखा [मेरे प्रतीत होता है सरल जवाब] (http://stackoverflow.com/questions/28694969/add-separate-legend-for- इस मुद्दे पर मेरे डेस्क पर मेरे सिर पर काफी जोर दे रहा था) geom-vline/28696738 # 28696738) एक बार ... – Henrik

संबंधित मुद्दे