मैं इसी तरह जवाब की तलाश में की है। लेकिन पाया कि opts
फ़ंक्शन अब ggplot2 पैकेज का हिस्सा नहीं है। कुछ और समय खोजने के बाद, मैंने पाया कि एक विकल्प के रूप में समान काम करने के लिए theme
का उपयोग कर सकते हैं। इसलिए इस धागे को संपादित करना, ताकि दूसरों को कम करने के लिए।
नीचे समान कोड है जैसा कि nzcoops द्वारा लिखा गया है।
mtcars$cyl <- factor(mtcars$cyl, labels=c("four","six","eight"))
library(gridExtra)
a <- ggplot(mtcars, aes(x=wt, y=mpg, colour=cyl)) + geom_point(aes(colour=cyl)) + labs(title = "Legend is top left") +
theme(legend.justification = c(0, 1), legend.position = c(0, 1))
b <- ggplot(mtcars, aes(x=wt, y=mpg, colour=cyl)) + geom_point(aes(colour=cyl)) + labs(title = "Legend is bottom right") +
theme(legend.justification = c(1, 0), legend.position = c(1, 0))
c <- ggplot(mtcars, aes(x=wt, y=mpg, colour=cyl)) + geom_point(aes(colour=cyl)) + labs(title = "Legend is bottom left") +
theme(legend.justification = c(0, 0), legend.position = c(0, 0))
d <- ggplot(mtcars, aes(x=wt, y=mpg, colour=cyl)) + geom_point(aes(colour=cyl)) + labs(title = "Legend is top right") +
theme(legend.justification = c(1, 1), legend.position = c(1, 1))
grid.arrange(a,b,c,d)
यह कोड बिल्कुल समान साजिश देगा।
स्रोत
2016-02-04 06:06:07
"साजिश क्षेत्र" से आपका क्या मतलब है? वह क्षेत्र जो भूरे रंग से भरा हुआ है? – kohske
@ कोहस्के हां, ओपी मूल रूप से "डेटा क्षेत्र", या भूरे रंग के क्षेत्र के कोने में पौराणिक कथाओं को रखने के लिए 'legend.position' के लिए सही निर्देशांक निर्धारित करने में सक्षम होना चाहता है।जैसा कि मैंने चैट में उल्लेख किया है, मुझे संदेह है कि आपके जैसे किसी को ग्रिड समाधान के साथ वजन करना होगा। – joran
@joran तो, यह डिफ़ॉल्ट व्यवहार है और आपको केवल सही औचित्य निर्धारित करना है। – kohske