हिस्टोग्राम्स

ggplot2 के साथ डेटा विज़ुअलाइज़ेशन परिचय

Rick Scavetta

Founder, Scavetta Academy

आम प्लॉट प्रकार

Plot type Possible Geoms
स्कैटर प्लॉट्स points, jitter, abline, smooth, count
बार प्लॉट्स histogram, bar, col, errorbar
लाइन प्लॉट्स line, path
ggplot2 के साथ डेटा विज़ुअलाइज़ेशन परिचय

हिस्टोग्राम्स

ggplot(iris, aes(x = Sepal.Width)) + 
  geom_histogram()
  • बिन किए गए मानों का प्लॉट
    • यानी एक सांख्यिकीय फंक्शन
`stat_bin()` using `bins = 30`.
Pick better value with `binwidth`.

ggplot2 के साथ डेटा विज़ुअलाइज़ेशन परिचय

डिफ़ॉल्ट: 30 समान बिन्स

ggplot(iris, aes(x = Sepal.Width)) + 
  geom_histogram()
  • बिन किए गए मानों का प्लॉट
    • यानी एक सांख्यिकीय फंक्शन
# डिफ़ॉल्ट बिन चौड़ाई:
diff(range(iris$Sepal.Width))/30
[1] 0.08

ggplot2 के साथ डेटा विज़ुअलाइज़ेशन परिचय

सरल और अर्थपूर्ण बिन चौड़ाई

ggplot(iris, aes(x = Sepal.Width)) + 
  geom_histogram(binwidth = 0.1)
  • अपने डेटा के लिए अर्थपूर्ण बिन चौड़ाई हमेशा सेट करें.

  • बार्स के बीच कोई स्पेस नहीं.

ggplot2 के साथ डेटा विज़ुअलाइज़ेशन परिचय

टिक मार्क्स को फिर से पोज़िशन करें

ggplot(iris, aes(x = Sepal.Width)) + 
  geom_histogram(binwidth = 0.1,
                 center = 0.05)
  • अपने डेटा के लिए अर्थपूर्ण बिन चौड़ाई हमेशा सेट करें.

  • बार्स के बीच कोई स्पेस नहीं.

  • X अक्ष के लेबल बार्स के बीच आते हैं.

ggplot2 के साथ डेटा विज़ुअलाइज़ेशन परिचय

अलग-अलग Species

ggplot(iris, aes(x = Sepal.Width, 
                 fill = Species)) + 
  geom_histogram(binwidth = .1, 
                 center = 0.05)

ggplot2 के साथ डेटा विज़ुअलाइज़ेशन परिचय

डिफ़ॉल्ट पोज़िशन "stack" है

ggplot(iris, aes(x = Sepal.Width,
                 fill = Species)) + 
  geom_histogram(binwidth = .1, 
                 center = 0.05,
                 position = "stack") 

ggplot2 के साथ डेटा विज़ुअलाइज़ेशन परिचय

position = "dodge"

ggplot(iris, aes(x = Sepal.Width, 
                 fill = Species)) + 
  geom_histogram(binwidth = .1, 
                 center = 0.05, 
                 position = "dodge")

ggplot2 के साथ डेटा विज़ुअलाइज़ेशन परिचय

position = "fill"

ggplot(iris, aes(x = Sepal.Width, 
                 fill = Species)) + 
  geom_histogram(binwidth = .1, 
                 center = 0.05, 
                 position = "fill")  

ggplot2 के साथ डेटा विज़ुअलाइज़ेशन परिचय

अंतिम स्लाइड

ggplot2 के साथ डेटा विज़ुअलाइज़ेशन परिचय

Preparing Video For Download...