मुझे पारदर्शी पृष्ठभूमि के साथ आर से पीएनजी फ़ाइलों में ggplot2 ग्राफिक्स आउटपुट करने की आवश्यकता है। सब कुछ बुनियादी अनुसंधान ग्राफिक्स के साथ ठीक है, लेकिन ggplot2 के साथ कोई पारदर्शिता:ggplot2 का उपयोग कर आर में पारदर्शी पृष्ठभूमि के साथ ग्राफिक्स कैसे बनाएं?
d <- rnorm(100) #generating random data
#this returns transparent png
png('tr_tst1.png',width=300,height=300,units="px",bg = "transparent")
boxplot(d)
dev.off()
df <- data.frame(y=d,x=1)
p <- ggplot(df) + stat_boxplot(aes(x = x,y=y))
p <- p + opts(
panel.background = theme_rect(fill = "transparent",colour = NA), # or theme_blank()
panel.grid.minor = theme_blank(),
panel.grid.major = theme_blank()
)
#returns white background
png('tr_tst2.png',width=300,height=300,units="px",bg = "transparent")
p
dev.off()
वहाँ किसी भी तरह से ggplot2 के साथ पारदर्शी पृष्ठभूमि पाने के लिए है?
भी देखें [इस उत्तर] (http://stackoverflow.com/questions/41856399/how-plot-transparent-background-ggplot), वर्तमान सोल ution 'थीम (पैनल.बैकग्राउंड = element_rect (fill = "पारदर्शी", रंग = एनए), plot.background = element_rect (fill = "पारदर्शी", रंग = एनए) जोड़ने के लिए है' ' –