Created
February 1, 2021 19:37
-
-
Save benfasoli/2ab7dcd7e338a8e6e3372d81f42c3783 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
library(ggplot2) | |
library(metR) | |
time <- Sys.time() | |
n <- 50 | |
data <- data.frame( | |
time = seq(time - 3600, time, length.out = n), | |
direction = seq(0, 359, length.out = n), | |
magnitude = 5 * sin(seq(0, 2 * pi, length.out = n)) | |
) | |
fig <- ggplot(data) + | |
# Use start = -90 and direction = 'cw' for north-relative clockwise | |
geom_arrow(aes(x = time, y = 0, mag = magnitude, angle = direction), | |
start = -90, direction = 'cw', pivot = 0) + | |
# Set arrow size in legend reference | |
scale_mag_continuous(max = 2, | |
labels = expression(2 ~ m ~ s^{-1})) + | |
# Remove dark background and unneccessary figure elements | |
theme_classic() + | |
# Remove y axis text and position legend inside figure | |
theme(axis.title.y = element_blank(), | |
axis.text.y = element_blank(), | |
axis.ticks.y = element_blank(), | |
axis.line.y = element_blank(), | |
legend.position = c(0.8, 0.2)) + | |
# Remove x axis and legend labels | |
labs(x = NULL, | |
mag = NULL) | |
fig | |
ggsave('figure.png', fig, width = 5, height = 2) |
Author
benfasoli
commented
Feb 1, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment