Incidencia acumulada

Row

Casos por 100.000 hab en 14 días

p <- data_cases_sp_provinces  %>% mutate( 
  cases_PCR_14days = ifelse( ccaa=="Galicia" | ccaa=="Andalucía", cases_14days, cases_PCR_14days)
)  %>% filter( !(is.na(ia14) & date > as.Date("2020-08-10") ) ) %>%
  ggplot() +
  # geom_line(aes(date, daily_cases,group=province, color=ccaa), size= 0.8 ) +
  geom_line( aes(date, ia14,group=province, color=ccaa, text = paste0("<b>", province, " (", ccaa, ")</b><br>", format( round(ia14, digits = 1),
                                                                                big.mark=".", decimal.mark = ","), "" ,"<br>",date )), size= 0.4
             
) +
  # geom_point(aes(date, daily_cases, color=ccaa), size= 1 ) +
  # geom_point(aes(date, cases_PCR_14days/poblacion*100000, color=ccaa), size= 0.4 ) +
  # geom_text_repel(
  #   data = data_cases_sp_provinces %>% group_by(province) %>% filter( !is.na(cases_PCR_14days) ) %>% top_n(1, date) %>% 
  #     filter ( cases_PCR_14days/poblacion*100000 > 15 & date > filter_date-4),
  #   # data=filter( data_cases_sp_provinces, date==max(data_cases_sp_provinces$date) & cases_14days/poblacion*100000 > 40),
  #   aes(date, cases_PCR_14days/poblacion*100000, color=ccaa, 
  #       label=paste(format( round(cases_PCR_14days/poblacion*100000, digits = 1), nsmall=1, big.mark=".", decimal.mark = ","),province)),
  #   nudge_x = 2, # adjust the starting y position of the text label
  #   size=5,
  #   hjust=0,
  #   family = "Roboto Condensed",
  #   direction="y",
  #   segment.size = 0.1,
  #   segment.color="#777777"
  # ) +
  scale_color_manual(values = colors_prov) +
  coord_cartesian(
    # ylim = c( 0,max(data_cases_sp_provinces[!is.na(data_cases_sp_provinces$daily_cases),]$daily_cases) )
  ) +
  scale_y_continuous( labels=function(x) format(round(x, digits = 0), big.mark = ".", scientific = FALSE)
  ) +
  # scale_y_log10( labels=function(x) format(round(x, digits = 0), big.mark = ".", scientific = FALSE),
  #                minor_breaks = c(seq(1 , 10, 1),seq(10 , 100, 10), seq(100 , 1000, 100), seq(1000 , 10000, 1000)),
  #                expand = c(0,0.2) ) +
  scale_x_date(date_breaks = "3 week", 
               date_labels = "%d/%m",
               limits=c( min(data_cases_sp_provinces$date)+15, max(data_cases_sp_provinces$date)),
               expand = c(0,0) 
  ) + 
  theme_minimal(base_family = "Roboto Condensed",base_size = 16) +
  theme(
    panel.grid.minor.x = element_blank(),
    panel.grid.major.x = element_blank(),
    # panel.grid.minor.y = element_blank(),
    axis.ticks.x = element_line(color = "#000000"),
    legend.position = "right"
  ) +
  labs(title = paste0("Incidencia acumulada 14 días COVID-19 en España ", updated),
       subtitle = paste0("Casos por 100.000 habitantes en últimos 14 días por provincia ",period),
       y = "Incidencia acumulada 14 días",
       x = "2020-2021",
       color = "CCAA",
       caption = caption_provincia)
## Warning: Ignoring unknown aesthetics: text
# save interactvive
p <- ggplotly( p, tooltip = "text") %>%
  layout(title = list(text = paste0('Incidencia acumulada 14 días COVID-19 en España',
                                    '<br>',
                                    '<sup>',
                                    'Casos por 100.000 habitantes en últimos 14 días por provincia.',
                                    '</sup>'))
         , annotations =
           list(x = 1, y = -0.11, text = "<a style='color:grey;' href='https://lab.montera34.com/covid19'>lab.montera34.com/covid19</a> | Data: <a  style='color:grey;'href='https://github.com/montera34/escovid19data9'>esCOVID19data</a>",
                showarrow = F, xref='paper', yref='paper',
                xanchor='right', yanchor='auto', xshift=0, yshift=0,
                font=list(size=15, color="grey")
           ),
         legend = list(font = list(size = 10))
  )
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' and 'decimal.mark' are both '.', which could be confusing
p