plot and mapped attributes part 1
play

Plot and Mapped Attributes (Part 1) Omayma Said Data Scientist - PowerPoint PPT Presentation

DataCamp Interactive Data Visualization with rbokeh INTERACTIVE DATA VISUALIZATION WITH RBOKEH Plot and Mapped Attributes (Part 1) Omayma Said Data Scientist DataCamp Interactive Data Visualization with rbokeh Aesthetic attributes color


  1. DataCamp Interactive Data Visualization with rbokeh INTERACTIVE DATA VISUALIZATION WITH RBOKEH Plot and Mapped Attributes (Part 1) Omayma Said Data Scientist

  2. DataCamp Interactive Data Visualization with rbokeh Aesthetic attributes color size transparency line type shape

  3. DataCamp Interactive Data Visualization with rbokeh Color Attributes (Default Color) figure(title = "Life Expectancy Vs. GDP per Capita in 1992" ) %>% ly_points(x = gdpPercap, y = lifeExp, data = dat_1992)

  4. DataCamp Interactive Data Visualization with rbokeh Color Attributes (Mapping Variables) figure(legend_location = "bottom_right", title = "Life Expectancy Vs. GDP per Capita in 1992" ) %>% ly_points(x = gdpPercap, y = lifeExp, data = dat_1992, color = continent)

  5. DataCamp Interactive Data Visualization with rbokeh HDI Dataset Human Development Index (HDI) data by UNDP > hdi_data country year human_development_index <chr> <int> <dbl> 1 Afghanistan 1990 0.295 2 Albania 1990 0.635 3 Algeria 1990 0.577 4 Andorra 1990 NA 5 Angola 1990 NA 6 Antigua and Barbuda 1990 NA 7 Argentina 1990 0.705 8 Armenia 1990 0.634 9 Australia 1990 0.866 10 Austria 1990 0.794 # ... with 4,878 more rows

  6. DataCamp Interactive Data Visualization with rbokeh HDI Dataset Human Development Index (HDI) data by UNDP The HDI is a summary measure of average achievement in three dimensions of human development: a long and healthy life being knowledgeable having a decent standard of living

  7. DataCamp Interactive Data Visualization with rbokeh Color Attributes (Line and Fill) ## plot human_development_index versus year hdi_countries <- hdi_data %>% filter(country %in% c("Hungary", "Bulgaria", "Poland")) fig_col <- figure(data = hdi_countries, legend_location = "bottom_right") %>% ly_lines(x = year, y = human_development_index, color = country) %>% ly_points(x = year, y = human_development_index, color = country) ## View plot fig_col

  8. DataCamp Interactive Data Visualization with rbokeh Color Attributes (Line and Fill)

  9. DataCamp Interactive Data Visualization with rbokeh Color Attributes (Line and Fill) ly_points() ly_lines() line_color line_color fill_color

  10. DataCamp Interactive Data Visualization with rbokeh Color Attributes (Line and Fill) figure(legend_location = "bottom_right") %>% ly_points(x = year, y = human_development_index, data = hdi_countries, color = country) line_color = color fill_color = color (with the alpha level of the fill reduced by 50%)

  11. DataCamp Interactive Data Visualization with rbokeh Color Attributes (Line and Fill) ## plot human_development_index versus year fig_col <- figure(data = hdi_countries, legend_location = "bottom_right") %>% ly_points(x = year, y = human_development_index, fill_color = country, fill_alpha = 1) %>% ly_lines(x = year, y = human_development_index, color = country) ## view plot fig_col

  12. DataCamp Interactive Data Visualization with rbokeh Color Attributes (Line and Fill)

  13. DataCamp Interactive Data Visualization with rbokeh Color Palettes ## plot human_development_index versus year and map color to country fig_col <- figure(data = hdi_countries, legend_location = "bottom_right") %>% ly_points(x = year, y = human_development_index, fill_color = country, fill_alpha = 1) %>% ly_lines(x = year, y = human_development_index, color = country) fig_col %>% set_palette(discrete_color = pal_color(c("#3182bd", "#31a354", "#de2d26")))

  14. DataCamp Interactive Data Visualization with rbokeh Color Palettes fig_col %>% set_palette(discrete_color = pal_color(c("#3182bd", "#31a354", "#de2d26")))

  15. DataCamp Interactive Data Visualization with rbokeh INTERACTIVE DATA VISUALIZATION WITH RBOKEH Now it is your turn!

  16. DataCamp Interactive Data Visualization with rbokeh INTERACTIVE DATA VISUALIZATION WITH RBOKEH Plot and Mapped Attributes (Part 2) Omayma Said Data Scientist

  17. DataCamp Interactive Data Visualization with rbokeh Bechdel Dataset fivethirtyeight package The raw data behind the story "The Dollar-And-Cents Case Against Hollywood's Exclusion of Women"

  18. DataCamp Interactive Data Visualization with rbokeh Bechdel Dataset fivethirtyeight package Three criteria to pass the bechdel test: there are at least two named women in the picture they have a conversation with each other at some point that conversation isn’t about a male character

  19. DataCamp Interactive Data Visualization with rbokeh Bechdel Dataset > library(fivethirtyeight) > str(bechdel) Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1794 obs. of 15 variables: $ year : int 2013 2012 2013 2013 2013 2013 2013 2013 2013 2013 ... $ imdb : chr "tt1711425" "tt1343727" "tt2024544" "tt1272878" ... $ title : chr "21 & Over" "Dredd 3D" "12 Years a Slave" "2 Guns" ... $ test : chr "notalk" "ok-disagree" "notalk-disagree" "notalk" ... $ clean_test : Ord.factor w/ 5 levels "nowomen"<"notalk"<..: 2 5 2 2 3 3 2 5 $ binary : chr "FAIL" "PASS" "FAIL" "FAIL" ... $ budget : int 13000000 45000000 20000000 61000000 40000000 225000000 92 $ domgross : num 25682380 13414714 53107035 75612460 95020213 ... $ intgross : num 4.22e+07 4.09e+07 1.59e+08 1.32e+08 9.50e+07 ... $ code : chr "2013FAIL" "2012PASS" "2013FAIL" "2013FAIL" ... $ budget_2013 : int 13000000 45658735 20000000 61000000 40000000 225000000 92 $ domgross_2013: num 25682380 13611086 53107035 75612460 95020213 ... $ intgross_2013: num 4.22e+07 4.15e+07 1.59e+08 1.32e+08 9.50e+07 ... $ period_code : int 1 1 1 1 1 1 1 1 1 1 ... $ decade_code : int 1 1 1 1 1 1 1 1 1 1 ...

  20. DataCamp Interactive Data Visualization with rbokeh Bechdel Dataset (Revenue versus Budget) figure() %>% ly_points(x = budget_2013, y = intgross_2013, data = dat_90_13)

  21. DataCamp Interactive Data Visualization with rbokeh Bechdel Dataset (Variables Distributions) figure() %>% figure() %>% ly_hist(x = intgross_2013, ly_hist(x = budget_2013, data = dat_90_13) data = dat_90_13)

  22. DataCamp Interactive Data Visualization with rbokeh Bechdel Dataset (Variables Distributions) figure() %>% figure() %>% ly_hist(x = log(intgross_2013), ly_hist(x = log(budget_2013), data = dat_90_13) data = dat_90_13)

  23. DataCamp Interactive Data Visualization with rbokeh Overplotting figure() %>% ly_points(x = log(budget_2013), y = log(intgross_2013), data = dat_90_13)

  24. DataCamp Interactive Data Visualization with rbokeh Overplotting (Alpha and Point Size) figure() %>% ly_points(x = log(budget_2013), y = log(intgross_2013), data = dat_90_13, alpha = 0.4, size = 5)

  25. DataCamp Interactive Data Visualization with rbokeh Line Width ## filter hdi data hdi_countries <- hdi_data %>% filter(country %in% c("Rwanda", "Kenya", "Botswana")) # A tibble: 78 x 3 country year human_development_index <chr> <int> <dbl> 1 Botswana 1990 0.585 2 Kenya 1990 0.473 3 Rwanda 1990 0.244 4 Botswana 1991 0.592 5 Kenya 1991 0.471 6 Rwanda 1991 0.22 7 Botswana 1992 0.59 8 Kenya 1992 0.468 9 Rwanda 1992 0.206 10 Botswana 1993 0.587 # ... with 68 more rows

  26. DataCamp Interactive Data Visualization with rbokeh Line Width ## plot human_development_index over time figure(title = "Human Development Index over Time", legend = "bottom_right") %>% ly_lines(x = year, y = human_development_index, data = hdi_countries, color = country)

  27. DataCamp Interactive Data Visualization with rbokeh Line Width figure(title = "Human Development Index over Time", legend = "bottom_right") %>% ly_lines(x = year, y = human_development_index, data = hdi_countries, color = country, width = 3)

  28. DataCamp Interactive Data Visualization with rbokeh INTERACTIVE DATA VISUALIZATION WITH RBOKEH Let's try some examples!

  29. DataCamp Interactive Data Visualization with rbokeh INTERACTIVE DATA VISUALIZATION WITH RBOKEH Hover info & Figure Options Omayma Said Data Scientist

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend