Created
June 12, 2017 17:09
-
-
Save robwschlegel/7bfbdbd29d77efac8cd7dc77754615b1 to your computer and use it in GitHub Desktop.
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
ggplot(data = ERA_pixel, aes(x = date, y = y_axis)) + | |
# Here we create the wind vectors as a series of segments with arrow tips | |
geom_segment(aes(x = date, xend = date + u*wind_scale, y = 0, yend = v*wind_scale), | |
arrow = arrow(length = unit(0.15, 'cm')), size = 0.5, alpha = 0.7) + | |
# I think adding points at the base of the vectors makes the figure easier to read | |
geom_point(aes(x = date, y = 0), alpha = 0.5, size = 1) + | |
# Changing the dates to better match the range shown on the x axis | |
scale_x_date(labels = date_format('%Y-%m-%d'), breaks = date_breaks('4 days')) + | |
# Change the y axis labels to make sense | |
scale_y_continuous(breaks = y_axis, labels = as.character(abs(y_axis)/wind_scale)) + | |
# Change the x and y axis labels | |
labs(x = NULL, y = 'Wind Speed (m/s)') + | |
coord_equal(ylim = c(min(y_axis/wind_scale), max(y_axis/wind_scale))) + | |
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