अपनी bar और point charts ट्यून करें

R में Visualization की Best Practices

Nick Strayer

Instructor

भीड़भाड़ वाला bar chart

who_disease %>% 
  filter(region == 'EMR', disease == 'measles', year == 2015) %>% 
  ggplot(aes(x = country, y = cases)) +
    geom_col()
R में Visualization की Best Practices

R में Visualization की Best Practices

बार्स को फ्लिप करना

  • geom_bar() और geom_col() y-axis पर categories नहीं देते हैं
    busy_bars <- who_disease %>% 
    filter(region == 'EMR', disease == 'measles', year == 2015) %>% 
    ggplot(aes(x = country, y = cases)) +
    geom_col() 
    
  • इसलिए हमें flip करना होगा!
busy_bars + coord_flip() # x और y axes बदलें!
R में Visualization की Best Practices

R में Visualization की Best Practices

अतिरिक्त ग्रिड

  • बार्स में समानांतर grid lines की ज़रूरत नहीं होती
  • point charts में, केवल points की पंक्ति में grids चाहिए

R में Visualization की Best Practices

R में Visualization की Best Practices

वर्टिकल ग्रिड हटाना

plot <- who_disease %>% 
  filter(country == "India", year == 1980) %>% 
  ggplot(aes(x = disease, y = cases)) +
    geom_col()
# वर्टिकल grid lines हटाएँ
 plot + theme(
    panel.grid.major.x = element_blank()
  )
R में Visualization की Best Practices

R में Visualization की Best Practices

point charts के लिए हल्का बैकग्राउंड

  • डिफॉल्ट gray बैकग्राउंड points के लिए कम contrast दे सकता है
  • theme_minimal() तुरंत सुधार है
  • points बड़े करना भी मदद करता है
who_subset %>% 
  ggplot(aes(y = reorder(country, cases_2016), x = log10(cases_2016))) +
  # Point size बढ़ाया गया
  geom_point(size = 2) +
  # हल्के बैकग्राउंड के लिए theme_minimal
  theme_minimal()
R में Visualization की Best Practices

R में Visualization की Best Practices

आइए इसे आज़माएँ!

R में Visualization की Best Practices

Preparing Video For Download...