Skip to content

Instantly share code, notes, and snippets.

@ozagordi
Last active November 23, 2015 10:03
Show Gist options
  • Select an option

  • Save ozagordi/7f7104cbfc52a5f186b5 to your computer and use it in GitHub Desktop.

Select an option

Save ozagordi/7f7104cbfc52a5f186b5 to your computer and use it in GitHub Desktop.
Visitors of EXPO Milano 2015 in the last three months

Visitors of EXPO Milano 2015 in the last three months, data from EXPO website. Contains theme_agile from Robert Wilson.

giorno data ingressi
Saturday 1 agosto 112202
Sunday 2 agosto 113290
Monday 3 agosto 99824
Tuesday 4 agosto 104936
Wednesday 5 agosto 108301
Thursday 6 agosto 93699
Friday 7 agosto 100391
Saturday 8 agosto 91489
Sunday 9 agosto 86686
Monday 10 agosto 104016
Tuesday 11 agosto 114522
Wednesday 12 agosto 112329
Thursday 13 agosto 108518
Friday 14 agosto 95130
Saturday 15 agosto 109578
Sunday 16 agosto 94899
Monday 17 agosto 112828
Tuesday 18 agosto 114627
Wednesday 19 agosto 130152
Thursday 20 agosto 153249
Friday 21 agosto 134386
Saturday 22 agosto 124872
Sunday 23 agosto 85888
Monday 24 agosto 87361
Tuesday 25 agosto 116099
Wednesday 26 agosto 130480
Thursday 27 agosto 128683
Friday 28 agosto 132557
Saturday 29 agosto 157801
Sunday 30 agosto 108572
Monday 31 agosto 111686
Tuesday 1 settembre 101204
Wednesday 2 settembre 104621
Thursday 3 settembre 109398
Friday 4 settembre 129562
Saturday 5 settembre 200919
Sunday 6 settembre 156677
Monday 7 settembre 142574
Tuesday 8 settembre 144498
Wednesday 9 settembre 138870
Thursday 10 settembre 146468
Friday 11 settembre 160203
Saturday 12 settembre 244994
Sunday 13 settembre 136951
Monday 14 settembre 108739
Tuesday 15 settembre 128445
Wednesday 16 settembre 107894
Thursday 17 settembre 112438
Friday 18 settembre 137209
Saturday 19 settembre 241938
Sunday 20 settembre 187747
Monday 21 settembre 140445
Tuesday 22 settembre 124168
Wednesday 23 settembre 104300
Thursday 24 settembre 151161
Friday 25 settembre 175670
Saturday 26 settembre 259093
Sunday 27 settembre 194649
Monday 28 settembre 147180
Tuesday 29 settembre 142997
Wednesday 30 settembre 143372
Thursday 1 ottobre 114424
Friday 2 ottobre 143607
Saturday 3 ottobre 226681
Sunday 4 ottobre 153371
Monday 5 ottobre 142331
Tuesday 6 ottobre 128368
Wednesday 7 ottobre 156891
Thursday 8 ottobre 152748
Friday 9 ottobre 178170
Saturday 10 ottobre 272785
Sunday 11 ottobre 212408
Monday 12 ottobre 159327
Tuesday 13 ottobre 127484
Wednesday 14 ottobre 136714
Thursday 15 ottobre 126683
Friday 16 ottobre 176346
Saturday 17 ottobre 246065
Sunday 18 ottobre 185004
Monday 19 ottobre 150728
Tuesday 20 ottobre 155899
Wednesday 21 ottobre 158367
Thursday 22 ottobre 150401
Friday 23 ottobre 166403
Saturday 24 ottobre 238512
Sunday 25 ottobre 179956
Monday 26 ottobre 186471
Tuesday 27 ottobre 178426
Wednesday 28 ottobre 151753
Thursday 29 ottobre 166951
Friday 30 ottobre 184117
Saturday 31 ottobre 177848
library(ggplot2)
theme_agile <- function(base_size = 12, base_family = "Arial", plot.type = "formal", lines.lwd = 0.25, ticks.type = "outer", plot.grid = TRUE, axis.font = base_family, title.size = base_size*1.2, legend.size = base_size,
bg.col = ifelse(plot.type == "formal", "white", "#F0F0F0"), title.font = base_family , base.col = "black", axis.lines = TRUE,
minor.grid = ifelse(plot.grid, TRUE, FALSE), vert.grid = ifelse(plot.grid, TRUE, FALSE), ticks.length = ifelse(ticks.type == "outer", 0.2, -0.2), horz.grid = ifelse(plot.grid, TRUE, FALSE), alpha.leg = 0.1, bord.size = 0,
legend.bg = ifelse(plot.type == "formal", "white", "#F0F0F0"), strip.bg = ifelse(plot.type == "formal", "white", "grey80")){
theme_bw()+
ggplot2::theme(
# Plot margins and finally line annotations
plot.margin = grid::unit(c(1, 1, .5, .7), "cm"),
text = ggplot2::element_text(family = base_family, size = base_size),
axis.line = element_line(size = ifelse(axis.lines, grid::unit(lines.lwd, "mm"),0), color = "black"),
axis.ticks.length = grid::unit(ticks.length, "cm"),
axis.ticks.margin = grid::unit(ifelse(ticks.length > 0,0.25, -ticks.length + 0.25) , "cm"),
axis.text.x = ggplot2::element_text(size = base_size, colour = base.col, family = axis.font),
axis.text.y = ggplot2::element_text(size = base_size, colour = base.col, family = axis.font),
axis.title.y = ggplot2::element_text(size = base_size, colour = base.col, vjust = 1.5, family = axis.font),
axis.title.x = ggplot2::element_text(size = base_size,colour = base.col,vjust = -.5, family = axis.font),
panel.background = ggplot2::element_rect(fill = bg.col),
plot.background = ggplot2::element_rect(fill = bg.col),
panel.border = ggplot2::element_rect(colour = "black", fill=NA, size = bord.size),
panel.grid.major.x = ggplot2::element_line(colour = ifelse(vert.grid, "grey60",bg.col), size = ifelse(vert.grid,0.45, 0)),
panel.grid.minor.x = ggplot2::element_line(colour = ifelse(vert.grid, ifelse(minor.grid, "grey80",bg.col),bg.col), size = ifelse(vert.grid,0.35, 0)),
panel.grid.major.y = ggplot2::element_line(colour = ifelse(horz.grid, "grey60",bg.col), size = ifelse(horz.grid,0.45, 0)),
panel.grid.minor.y = ggplot2::element_line(colour = ifelse(horz.grid, ifelse(minor.grid, "grey80",bg.col),bg.col), size = ifelse(horz.grid,0.35, 0)),
panel.grid.major = ggplot2::element_line(colour = "grey40", size=0.45),
plot.title = ggplot2::element_text(face="bold",hjust = ifelse(plot.type == "formal", 0.5, 0) ,vjust = 2, colour = base.col, size = title.size, family = title.font),
legend.background = ggplot2::element_rect(fill = scales::alpha(legend.bg, alpha.leg)), legend.key = ggplot2::element_blank(),
legend.text = ggplot2::element_text(size = legend.size),
legend.title = element_blank(),
strip.background = ggplot2::element_rect(fill = strip.bg),
strip.text.x = ggplot2::element_text(size = base_size + 1),
strip.text.y = ggplot2::element_text(size = base_size + 1)
)
}
cbPalette <- c("#E69F00", "#999999", "#56B4E9", "#009E73", "#F0E442", "#0072B2",
"#D55E00", "#CC79A7")
expo2015 <- read.csv("expo2015.csv")
start_date = '2015-08-01'
n_days = dim(expo2015)[1]
expo2015$data = seq(as.Date(start_date), len=n_days, by="1 day")
p = ggplot(expo2015, aes(x=data, y=ingressi, colour=factor(giorno)))
p = p + stat_smooth(aes(colour = factor(giorno)), alpha=0.0, size=1)
p = p + geom_point(size=3.5)
p = p + scale_colour_manual(values=cbPalette)
p = p + scale_colour_discrete(name="Giorno",
breaks=c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"),
labels=c('lun', 'mar', 'mer', 'gio', 'ven', 'sab', 'dom'))
p = p + theme_agile(base_size=13)
p = p + scale_y_continuous(breaks=c(100000, 200000, 300000), labels=c('100.000', '200.000', '300.000'))
p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment