Last active
July 5, 2017 16:46
-
-
Save grigory93/4c0d970a1ca47f22f251796edce5e635 to your computer and use it in GitHub Desktop.
Small Data Visualization - Vacation Recap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(googlesheets) | |
library(dplyr) | |
library(lubridate) | |
gsh = gs_title("Rome-Siracusa-vacations") | |
vdata = gsh %>% gs_read() | |
vdata$ts = mdy(vdata$Date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(ggthemes) | |
date_breaks = vdata$ts[is.na(ifelse(day(vdata$ts)%%2==1, NA, 1:length(vdata$ts)))] | |
date_labels = format(date_breaks, "%b-%d") | |
text_just = ifelse(vdata$Place == 'Rome', 0.25, 0.75) | |
ggplot(vdata) + | |
geom_line(aes(ts, Distance, group=1, color=Place), size=1) + | |
geom_point(aes(ts, Distance, color=Place), size=4) + | |
scale_x_date(breaks = date_breaks, labels = date_labels) + | |
geom_text(aes(ts, Distance, label=Label, hjust=text_just), nudge_y = -0.3, family='serif') + | |
scale_color_manual(values=c('darkred','olivedrab4'), name='Base Cities') + | |
theme_tufte(ticks = FALSE, base_size = 16, base_family = 'sans') + | |
theme(axis.text.x = element_text(angle = 0), | |
legend.position = "bottom") + | |
labs(title="Italian Vacation - June 19-30, 2017", | |
subtitle="Miles walked and major attractions each day", | |
x=NULL, y="Miles") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment