Skip to content

Instantly share code, notes, and snippets.

@benfasoli
Created February 1, 2021 19:37
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 benfasoli/2ab7dcd7e338a8e6e3372d81f42c3783 to your computer and use it in GitHub Desktop.
Save benfasoli/2ab7dcd7e338a8e6e3372d81f42c3783 to your computer and use it in GitHub Desktop.
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)
@benfasoli
Copy link
Author

figure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment