Skip to content

Instantly share code, notes, and snippets.

@robwschlegel
Created June 12, 2017 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robwschlegel/09cae87eb14f3ae004442baed4123484 to your computer and use it in GitHub Desktop.
Save robwschlegel/09cae87eb14f3ae004442baed4123484 to your computer and use it in GitHub Desktop.
# Reset the wind scale to 1
wind_scale <- 1
# Now we use temperature for the y axis, so some things must change
ggplot(data = ERA_pixel, aes(x = date, y = temp)) +
geom_line(colour = 'salmon', show.legend = F, size = 1.5) +
geom_segment(aes(x = date, xend = date + u,
y = mean(temp, na.rm = T), yend = mean(temp, na.rm = T) +v),
arrow = arrow(length = unit(0.15, 'cm')), size = 0.5, alpha = 0.7) +
geom_point(aes(x = date, y = mean(temp, na.rm = T)), alpha = 0.5, size = 1) +
# Create the label box for our wind vector length legend
geom_label(aes(x = as.Date('2016-12-04'), y = 22, label = ' 4 m/s \n'), size = 5) +
# Create the segment for the wind vector legend
geom_segment(aes(x = as.Date('2016-12-02'), xend = as.Date('2016-12-06'),
y = 21.4, yend = 21.4), size = 0.5, alpha = 0.7) +
scale_x_date(labels = date_format('%Y-%m-%d'), breaks = date_breaks('4 days')) +
labs(x = NULL, y = 'Temperature (°C)') +
# Here we choose to allow ggplot to determine the best range for y axis values
coord_equal() +
theme(axis.text.x = element_text(angle = 20, hjust = 0.4, vjust = 0.5, size = 8),
axis.text.y = element_text(size = 8))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment