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 size transparency line type shape
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)
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)
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
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
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
DataCamp Interactive Data Visualization with rbokeh Color Attributes (Line and Fill)
DataCamp Interactive Data Visualization with rbokeh Color Attributes (Line and Fill) ly_points() ly_lines() line_color line_color fill_color
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%)
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
DataCamp Interactive Data Visualization with rbokeh Color Attributes (Line and Fill)
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")))
DataCamp Interactive Data Visualization with rbokeh Color Palettes fig_col %>% set_palette(discrete_color = pal_color(c("#3182bd", "#31a354", "#de2d26")))
DataCamp Interactive Data Visualization with rbokeh INTERACTIVE DATA VISUALIZATION WITH RBOKEH Now it is your turn!
DataCamp Interactive Data Visualization with rbokeh INTERACTIVE DATA VISUALIZATION WITH RBOKEH Plot and Mapped Attributes (Part 2) Omayma Said Data Scientist
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"
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
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 ...
DataCamp Interactive Data Visualization with rbokeh Bechdel Dataset (Revenue versus Budget) figure() %>% ly_points(x = budget_2013, y = intgross_2013, data = dat_90_13)
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)
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)
DataCamp Interactive Data Visualization with rbokeh Overplotting figure() %>% ly_points(x = log(budget_2013), y = log(intgross_2013), data = dat_90_13)
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)
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
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)
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)
DataCamp Interactive Data Visualization with rbokeh INTERACTIVE DATA VISUALIZATION WITH RBOKEH Let's try some examples!
DataCamp Interactive Data Visualization with rbokeh INTERACTIVE DATA VISUALIZATION WITH RBOKEH Hover info & Figure Options Omayma Said Data Scientist
Recommend
More recommend