Description Usage Arguments Details Value
View source: R/plot_field_discrete.R
This function tries to produce high-quality maps of gridded fields using a discrete color-scale. The function is based on ggplot2
.
World borders will be used with the plot.
1 2 3 4 5 6 7 | plot_field_discrete(x, lon, lat, lonlim = "auto", latlim = "auto",
breaks = c(), labels = c(), color_scale = "Spectral",
rev_color_scale = F, show_lat_lon_labels = T, varname = "x",
mask = NULL, siglev = NULL, plot_only_sig = F, smooth = F,
smooth_factor = 5, smooth_theta = 0.5, line_width = 0.5,
dot_size = 0.5, grid_step = 10, font_size = 18,
show_legend = TRUE)
|
x |
The field to be plotted, it can be both a matrix or a vector. See Details for more information. |
lon |
Vector of longitude values. Longitude should be in the range c(-180, 180), otherwise it will be transformed |
lat |
Vector of latitude values |
lonlim |
A vector of two values defining the longitude limits for the plot. The default is 'auto': it tries to detect the extreme directly from the provided longitude values. |
latlim |
A vector of two values defining the latitude limits for the plot. The default is 'auto': it tries to detect the extreme directly from the provided latitude values. |
breaks |
The vector to be used to define the color scale. If the vector contains N values (n_1, n_2, ..., n_k), the scale will have N+1 intervals: "<n_1", "n_1, n_2", ..., ">n_k". If breaks are not defined they are automatically computed diving the range of the plotted field in 5 intervals. |
labels |
A character vector containing all the labels associated to the |
color_scale |
This parameter defines the color palette. It might be a string defining the name of a colorbrewer (see colorbrewer2.org) palette or a list of all the colors associated to each interval. |
rev_color_scale |
logical value to define if the |
show_lat_lon_labels |
logical value that defines if labels for longitude and latitude should be shown |
varname |
Name of the plotted variable that appears on the legend bar |
mask |
Field of the same size of |
siglev |
Scalar value that is used with |
plot_only_sig |
If |
smooth |
Logical value that defines if a smoothing will be applied to the field |
smooth_factor |
The amplitude of the smoothing, the value indicates the "multiplication factor", i.e. how many points are used for each original grid points |
line_width |
Line width used for the plot |
dot_size |
Size of the dots used to indicate the significance |
grid_step |
Interval used for the lat-lon grid |
font_size |
Size of the fonts used in the plot |
show_legend |
Logical value to define if the colorbar should be visible |
theta |
This is the |
Details
The field x
should be or a matrix/array with 2 dimensions (consistent with lat
and lon
) or a vector. In the latter, it should have the same length of lat
and lon
to have a list of grid points.
The returned ggplot
object can be then combined with other ggplot layers, including coord*
layers. We do not suggest to use projections because they are not well implemented with raster/tiles like in this case, especially when the latitude range is very close to the poles.
To have a good representation of the field we suggest to add the layer coord_equal()
or coord_quickmap()
Comments about smoothing, description of the procedure.
A ggplot object
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.