Fuente: @planaspa
Fuente: @rtve
library(ggplot2)
ggplot(df, aes(x=pib_dates, y=pib_values, fill=pib_names, text=paste0("PaÃs:",pib_names,"\n","PIB:",pib_values,"%"))) +
geom_col() +
facet_grid(~pib_names) +
labs(fill="PaÃses de la UE", title="La caÃda del PIB en la UE", x="1er y 2o trimestre 2020", y="Tasa de variación del PIB") +
#scale_y_continuous(labels = scales::percent)
scale_y_continuous(labels = function(x) paste(x,"%")) -> p
library(shades)
dark_palette <- saturation(base_palette, 0.1)
temp_palette <- c(rbind(dark_palette, base_palette))
ggplot(df, aes(x=pib_dates, y=pib_values,
fill=interaction(pib_dates,pib_names),
text=paste0("PaÃs:",pib_names,"\n","PIB:",pib_values,"%"))) +
geom_col() +
facet_grid(~pib_names) +
labs(fill="PaÃses de la UE",
title="La caÃda del PIB en la UE",
x="", y="Tasa de variación del PIB") +
scale_y_continuous(labels = function(x) paste(x,"%")) +
theme_minimal() +
scale_fill_manual(values=temp_palette) +
theme(legend.position = "none") -> p
ggplotly(p, tooltip="text")
library(highcharter)
series <- df %>%
group_by(pib_names) %>%
do(data = list(sequence = .$pib_values)) %>%
ungroup() %>%
group_by(pib_names) %>%
do(data = .$data) %>%
mutate(name = pib_names) %>%
list_parse()
highchart() %>%
hc_chart(type = "column") %>%
hc_add_series_list(series) %>%
hc_yAxis(max=0, min=-20) %>%
hc_xAxis(labels=list(enabled=F), tickColor='#fff', tickLength=40) %>%
hc_colors(colors = base_palette) %>%
hc_title(text="La caÃda del PIB en la UE") %>%
hc_subtitle(text="% Tasa de variación del PIB") %>%
hc_tooltip(headerFormat = "") %>%
hc_yAxis(labels = list(format = "{value}%")) %>%
hc_motion(
enabled = TRUE,
labels = c(pib_dates %>% levels()),
autoplay = TRUE,
series = seq(0,3,1))
@paulalcasado