# NOT RUN {
# Retrieve maximum wind gust data at the Reefton Ews station from CliFlo
# (public data)
reefton_wind = cf_query(cf_user(), cf_datatype(2, 2, 1, 1), cf_station(),
start_date = "2012-01-01-00")
class(reefton_wind)
# Examples of the default plots --------------------------------------------
# Plot a windrose
plot(reefton_wind)
# Plot the wind direction contours
direction_plot(reefton_wind)
# Plot the wind speed time-series
speed_plot(reefton_wind)
# Examples of changing the defaults ----------------------------------------
# Plot black and white windroses
plot(reefton_wind, ggtheme = "bw", col_pal = "Greys")
plot(reefton_wind, ggtheme = "linedraw", col_pal = "Greys")
plot(reefton_wind, ggtheme = "classic", col_pal = "Greys")
plot(reefton_wind, ggtheme = "minimal", col_pal = "Greys")
# Plot the wind directions using 20 contours and the ggtheme 'classic'
direction_plot(reefton_wind, ggtheme = "classic", contours = 20)
# Enlarge all the text to 18pt
library(ggplot2) # for element_text() and geom_point()
direction_plot(reefton_wind, ggtheme = "classic", contours = 20,
text = element_text(size = 18))
# Include the actual observations in the plots
direction_plot(reefton_wind) + geom_point(alpha = .2, size = 3)
speed_plot(reefton_wind, ggtheme = "classic", text = element_text(size = 16)) +
geom_point(shape = 1, size = 3)
# or equivalently using base graphics:
plot(reefton_wind$Date, reefton_wind$Speed, type = 'o',
xlab = NA, ylab = "Daily max gust (m/s)", las = 1, main = "Reefton Ews")
# Example of plotting a cfDataList -----------------------------------------
# Collect both surface wind run and hourly surface wind observations from
# Reefton Ews
reefton_list = cf_query(cf_user(), cf_datatype(2, 1, 1:2, 1),
cf_station(), "2012-01-01 00", "2012-02-01 00")
reefton_list
class(reefton_list) #cfDataList
# Plot the first (default) dataframe
plot(reefton_list) # Error - no wind directions for wind run datatypes
# Try speed_plot instead
speed_plot(reefton_list)
# Plot the second dataframe in the cfDataList
plot(reefton_list, 2) # identical to plot(reefton_list[2])
speed_plot(reefton_list, 2) # identical to speed_plot(reefton_list[2])
direction_plot(reefton_list, 2) # identical to direction_plot(reefton_list[2])
# Save the ggplot externally -----------------------------------------------
# Save the plot as a png to the current working directory
library(ggplot2) # for ggsave()
ggsave("my_wind_plot.png")
# }
Run the code above in your browser using DataLab