plot-cfWind-missing-method: Plot Clifro Wind Objects

Description Usage Arguments Details Theme Selection Note Examples

Description

Various plot methods for exploring wind speed and direction patterns for given CliFlo stations.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## S4 method for signature 'cfWind,missing'
plot(
  x,
  y,
  n_directions = 12,
  n_speeds = 5,
  speed_cuts = NULL,
  col_pal = "GnBu",
  ggtheme = c("grey", "gray", "bw", "linedraw", "light", "minimal", "classic"),
  n_col = 1,
  ...
)

## S4 method for signature 'cfWind,missing'
direction_plot(
  x,
  y,
  ggtheme = c("grey", "gray", "bw", "linedraw", "light", "minimal", "classic"),
  contours = 10,
  n_col = 1,
  ...
)

## S4 method for signature 'cfDataList,missing'
direction_plot(x, y, ...)

## S4 method for signature 'cfDataList,numeric'
direction_plot(x, y, ...)

## S4 method for signature 'cfWind,missing'
speed_plot(
  x,
  y,
  ggtheme = c("grey", "gray", "bw", "linedraw", "light", "minimal", "classic"),
  scales = c("fixed", "free_x", "free_y", "free"),
  n_col = 1,
  ...
)

## S4 method for signature 'cfDataList,missing'
speed_plot(x, y, ...)

## S4 method for signature 'cfDataList,numeric'
speed_plot(x, y, ...)

Arguments

x

a cfWind or cfDataList object.

y

missing if x is a .cfWind object, otherwise a number indicating the dataframe to plot in the cfDataList (defaults to 1).

n_directions

the number of direction bins to plot (petals on the rose). The number of directions defaults to 12.

n_speeds

the number of equally spaced wind speed bins to plot. This is used if spd_cuts is NA (default 5).

speed_cuts

numeric vector containing the cut points for the wind speed intervals, or NA (default).

col_pal

character string indicating the name of the RColorBrewer colour palette to be used for plotting, see 'Theme Selection' below.

ggtheme

character string (partially) matching the ggtheme to be used for plotting, see 'Theme Selection' below.

n_col

the number of columns of plots (default 1).

...

further arguments passed to theme.

contours

the number of contour lines to draw (default 10).

scales

character string partially matching the scales argument in the link[ggplot2]{facet_wrap} function.

Details

If x is a cfDataList, by default the first datatype will be plotted unless y is supplied.

Theme Selection

For black and white windroses that may be preferred if plots are to be used in journal articles for example, recommended ggthemes are 'bw', 'linedraw', 'minimal' or 'classic' and the col_pal should be 'Greys'. Otherwise, any of the sequential RColorBrewer colour palettes are recommended for colour plots.

Note

If x is a cfDataList object and y refers to a clifro dataframe that is not a cfWind object then it will be passed to another method, if available.

The default plot method plots a different windrose for each CliFlo station. The direction_plot method plots wind direction contours through time to visualise temporal patterns in wind directions. The speed_plot method plots the time series of wind speeds with a +/- standard deviation region (if applicable).

Given a value on the x-axis, the ends of the density function along the y-axis are not constrained to be equal for any of the derivatives for the direction_plot method. That is, the contours at direction = 0, do not match the contours at direction = 360.

@seealso plot,cfDataList,missing-method for general information on default plotting of cfData and cfDataList objects, and the links within. See cf_query for creating cfWind objects or windrose for plotting any wind data. Refer to theme for more possible arguments to pass to these methods. summary,cfWind-method for summarising wind information at each CliFlo station.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
## 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")

## End(Not run)

clifro documentation built on May 24, 2021, 9:06 a.m.