ggplot2
डेटा का सबसेट प्लॉट करें
खोज…
वाक्य - विन्यास
- xlim (left.limit, right.limit)
- data.frame [data.frame $ चर == "वांछित। सुलभ",]
Xlim / ylim का उपयोग करना
> library(ggplot2)
> ggplot(iris,aes(Sepal.Width)) + geom_density() + xlim(1,3.5)
Xlim या ylim का उपयोग करके प्लॉट को नहीं काटा जाता है, ggplot स्टेटमेंट फंक्शन (इस मामले में स्टेट_डेंसिटी) को कॉल करने से पहले डेटा को सब्मिट करता है। आप इसे चेतावनी संदेश में देख सकते हैं।
Warning message:
Removed 19 rows containing non-finite values (stat_density).
श्रेणीबद्ध चर के लिए इनलाइन सबसेटिंग
ggplot(iris[iris$Species == "setosa",],aes(Sepal.Width)) +
geom_density()
यहां, हम ggplot को पास करने से पहले डेटाफ्रेम को कम कर रहे हैं। यह डेटा फ्रेम डेटा संरचना से प्राप्त एक बहुत ही उपयोगी उपकरण है।
कोड को अधिक पठनीय बनाने के लिए, व्यक्ति dplyr के filter का भी उपयोग कर सकता है:
library(dplyr)
iris %>% filter(Species == "setosa") %>% ggplot(aes(Sepal.Width)) +
geom_density()
Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow