dss-ialh / graph-making-scenarios

A series of analytical scenarios for learning graph-making techniques through reproducible examples
GNU General Public License v2.0
3 stars 3 forks source link

Suggest your modification to the existing plot #2

Open andkov opened 5 years ago

andkov commented 5 years ago
g1 <- ds1 %>% 
  dplyr::filter(area       ==  "British Columbia" ) %>%
  dplyr::filter(age_group  ==  "20-34" ) %>%
  dplyr::filter(sex       %in% c("Males","Females") ) %>%
  ggplot(aes(
    x      = year
    ,y     = rate
    ,color = sex
  ))+
  geom_point()+
  geom_line( aes(group = sex) )+
  theme_minimal()+
  labs( title = "Crude prevalence of MH service utilization in BC among 20-34 year olds")
g1

image

mrparker909 commented 5 years ago

NOTE: requires the viridis package for the viridis colours.

g2 <- ds1 %>% 
  dplyr::filter(area       ==  "British Columbia" ) %>%
  dplyr::filter(age_group  ==  "20-34" ) %>%
  dplyr::filter(sex       %in% c("Males","Females") ) %>%
  ggplot(aes(
    x      = year
    ,y     = rate
    ,color = sex
  ))+
  geom_point()+
  geom_line( aes(group = sex) )+
  theme_classic(base_size = 12) +
  scale_color_viridis_d(end = 0.5) +
  labs( title = "Crude prevalence of MH service utilization\nin BC among 20-34 year olds")
g2

g2

Zhan-L commented 5 years ago
quick_save <- function(g,name){
  ggplot2::ggsave(
    filename  = paste0(name,".png"), 
    plot      = g,
    device    = png,
    path  = where_to_store_graphs,
    width     = 1000,
    height    = 400,
    res       = 150,
    limitsize = FALSE
  )
}

image

prasoon2012 commented 5 years ago
`g1 <- ds1 %>% 
  dplyr::filter(area       ==  "British Columbia" ) %>%
  dplyr::filter(age_group  ==  "20-34" ) %>%
  dplyr::filter(sex       %in% c("Males","Females") ) %>%
  ggplot(aes(
    x      = year
    ,y     = rate
    ,color = sex
  ))+
  geom_point()+
  geom_line( aes(group = sex) )+
  theme_minimal()+
  labs( title = "Crude prevalence of MH service utilization in BC among 20-34 year olds")
g1`
Screen Shot 2019-06-13 at 09 18 25
olawaleayilara commented 5 years ago
g2 <- ds1 %>% 
  dplyr::filter(area       %in%  c("Manitoba","Saskatchewan","Alberta","British Columbia") )%>%
  dplyr::filter(age_group  ==  "20-34" ) %>%
  dplyr::filter(sex       %in% c("Males","Females") ) %>%
  ggplot(aes(
    x      = year
    ,y     = rate
    ,color = sex
  ))+
  facet_wrap(~area) +
  geom_point()+
  geom_line( aes(group = sex) )+
  theme_minimal()+
  labs( title = "Crude prevalence of MH service utilization in Western Canada among 20-34 year olds")
g2
Screen Shot 2019-06-13 at 9 20 37 AM
mnesca commented 5 years ago

Manitoba for 80+ year olds.

g1 <- ds1 %>% 
  dplyr::filter(area       ==  "Manitoba" ) %>%
  dplyr::filter(age_group  ==  "80+" ) %>%
  dplyr::filter(sex       %in% c("Males","Females") ) %>%
  ggplot(aes(
    x      = year
    ,y     = rate
    ,color = sex
  ))+
  geom_point()+
  geom_line( aes(group = sex) )+
  theme_minimal()+
  labs( title = "Crude prevalence of MH service utilization in MB among 80+ year olds")
g1

g1 %>% quick_save(name  = "graph-mn") # will produce error, debug

image

andkov commented 5 years ago
g1 <- ds1 %>% 
  dplyr::filter(area       ==  "British Columbia" ) %>%
  dplyr::filter(age_group  ==  "20-34" ) %>%
  dplyr::filter(sex       %in% c("Males","Females") ) %>%
  ggplot(aes(
    x      = year
    ,y     = rate
    ,color = sex
  ))+
  geom_point(shape = 21, size = 3)+
  geom_smooth(method = "lm", se = FALSE, size = .2, )+
  geom_line( aes(group = sex) )+
  theme_bw()+
  labs( title = "Crude prevalence of MH service utilization in BC among 20-34 year olds")
g1

image

andkov commented 5 years ago
g1 <- ds1 %>% 
  dplyr::filter(area       ==  "British Columbia" ) %>%
  dplyr::filter(age_group  ==  "20-34" ) %>%
  dplyr::filter(sex       %in% c("Males","Females") ) %>%
  ggplot(aes(
    x      = year
    ,y     = rate
    ,color = sex
  ))+
  geom_point(shape = 21, size = 3)+
  geom_smooth(method = "lm", se = FALSE, size = .2 )+
  geom_line( aes(group = sex) )+
  theme_bw()+
  labs( title = "Crude prevalence of MH service utilization \n\n in BC among 20-34 year olds")
g1

image