ggplot()+geom_point(DATA,aes(X,Y)) (Normal) hchart(DATA,'scatter',hcaes(X,Y)) (Interactif) slice() en Manipulation de données library(ggplot)
ggplot(data= YOUR_DATASET)+
geom_bar(aes(x= X_AXIS_VAR, y= Y_AXIS_VAR, fill= COLOR_VAR), stat="identity") +
ggtitle("YOUR TITLE")+ # The Graph title
xlab("YOUR X LABEL") + # If you want something different
ylab("YOUR Y LABEL") + # from X_AXIS_VAR & Y_AXIS_VAR
theme_minimal() + # Optional
theme(plot.title = element_text(size = 15, hjust = 0.5), # Optional
panel.grid.minor = element_blank(), # Optional
panel.grid.major.x = element_blank(), # Optional
)fish_ca_data.csv fish <- read_csv('/data/session5/fish_ca_data.csv')
fish <- fish %>%
clean_names() %>%
filter(value!=':' & time<2019) %>%
mutate(value=as.numeric(str_remove_all(value,'[[:space:]]')),
geo = ifelse(str_detect(geo,'Germany'),'Germany', geo)) %>%
select(-flag_and_footnotes)
ggplot(fish %>% filter(geo=='Norway' & time<=2016)) +
geom_bar(aes(x=time, y=value/10^6, fill=geo),
stat="identity", position=position_dodge())+
ggtitle("Evolution du volume de la pêche\nen Norvège entre 2000 et 2016") +
ylab("Poids* (millions de tonnes)") +
xlab("Année") +
theme_minimal() +
theme(plot.title = element_text(size = 15, face = "bold", hjust = 0.5),
panel.grid.minor.x = element_blank(),
panel.grid.major.x = element_blank(),
legend.position = 'none') +
expand_limits(y = c(0,3))geom_bar(, position=position_dodge())sub_geo <- c("Norway", "Spain", "Denmark", "United Kingdom" )
sub_fish <- fish %>%
filter(geo %in% sub_geo & time>=2010 & time <=2016) %>%
mutate(iso = case_when( geo=="Denmark" ~ "DK",
geo=="United Kingdom" ~ "UK",
geo=="Spain" ~ "ES",
geo=="Norway" ~ "NO"),
geo= factor(geo, levels = sub_geo))
ggplot(sub_fish, aes(x=time, y=value/10^6,
fill=geo)) +
geom_bar(stat="identity", width=0.8,
position=position_dodge(width=0.9))+
scale_fill_manual(values=c('#6891d0', '#b2b4b7', '#b2b4b7', '#b2b4b7')) +
ggtitle("Evolution du volume de la pêche\nentre 2010 et 2016") +
labs(fill="",
caption = "Source: Eurostat")+
ylab("Poids* (millions de tonnes)") +
xlab("Année") +
theme_minimal() +
theme(plot.title = element_text(size = 15,
face = "bold", hjust = 0.5),
panel.grid.minor.x = element_blank(),
panel.grid.major.x = element_blank(),
legend.position = 'bottom')+
expand_limits(y = c(0,3))hchart(sub_fish, "column", hcaes(x=time, group = geo, y = round(value/10^6,2)),
color=c('#6891d0', '#b2b4b7', '#b2b4b7', '#b2b4b7')) %>%
hc_tooltip(pointFormat = "{point.geo}: <b>{point.y}</b>") %>%
hc_title( text="Evolution du volume de la pêche<br>entre 2010 et 2016") %>%
hc_xAxis(title = list(text = "Année")) %>%
hc_yAxis(title = list(text = "Poids* (millions de tonnes)")) %>%
hc_credits(
enabled = TRUE, text = "Source: Eurostat",
href = "https://ec.europa.eu/eurostat/web/fisheries/data/database",
style = list(fontSize = "12px"))ggplot()+geom_bar(DATA,aes(X,Y)) (Normal) hchart(DATA,'column',hcaes(X,Y)) (Interactif) Merci pour votre attention