geom_rect_pattern | R Documentation |
All geoms in this package are identical to their counterparts in ggplot2 except that they can be filled with patterns.
geom_rect_pattern( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_bar_pattern( mapping = NULL, data = NULL, stat = "count", position = "stack", ..., width = NULL, binwidth = NULL, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) geom_histogram_pattern( mapping = NULL, data = NULL, stat = "bin", position = "stack", ..., binwidth = NULL, bins = NULL, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) geom_bin2d_pattern( mapping = NULL, data = NULL, stat = "bin2d", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_boxplot_pattern( mapping = NULL, data = NULL, stat = "boxplot", position = "dodge2", ..., outlier.colour = NULL, outlier.color = NULL, outlier.fill = NULL, outlier.shape = 19, outlier.size = 1.5, outlier.stroke = 0.5, outlier.alpha = NULL, notch = FALSE, notchwidth = 0.5, varwidth = FALSE, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) geom_col_pattern( mapping = NULL, data = NULL, position = "stack", ..., width = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_crossbar_pattern( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., fatten = 2.5, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) geom_ribbon_pattern( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE, outline.type = "both" ) geom_area_pattern( mapping = NULL, data = NULL, stat = "identity", position = "stack", na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE, ..., outline.type = "upper" ) geom_density_pattern( mapping = NULL, data = NULL, stat = "density", position = "identity", ..., na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) geom_polygon_pattern( mapping = NULL, data = NULL, stat = "identity", position = "identity", rule = "evenodd", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_map_pattern( mapping = NULL, data = NULL, stat = "identity", ..., map, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_sf_pattern( mapping = aes(), data = NULL, stat = "sf", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... ) geom_tile_pattern( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_violin_pattern( mapping = NULL, data = NULL, stat = "ydensity", position = "dodge", ..., draw_quantiles = NULL, trim = TRUE, scale = "area", na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this
layer, either as a |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Other arguments passed on to |
linejoin |
Line join style (round, mitre, bevel). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
width |
Bar width. By default, set to 90% of the |
binwidth |
The width of the bins. Can be specified as a numeric value
or as a function that calculates width from unscaled x. Here, "unscaled x"
refers to the original x values in the data, before application of any
scale transformation. When specifying a function along with a grouping
structure, the function will be called once per group.
The default is to use the number of bins in The bin width of a date variable is the number of days in each time; the bin width of a time variable is the number of seconds. |
orientation |
The orientation of the layer. The default ( |
bins |
Number of bins. Overridden by |
outlier.colour, outlier.color, outlier.fill, outlier.shape, outlier.size, outlier.stroke, outlier.alpha |
Default aesthetics for outliers. Set to In the unlikely event you specify both US and UK spellings of colour, the US spelling will take precedence. Sometimes it can be useful to hide the outliers, for example when overlaying
the raw data points on top of the boxplot. Hiding the outliers can be achieved
by setting |
notch |
If |
notchwidth |
For a notched box plot, width of the notch relative to
the body (defaults to |
varwidth |
If |
fatten |
A multiplicative factor used to increase the size of the
middle bar in |
outline.type |
Type of the outline of the area; |
rule |
Either |
map |
Data frame that contains the map coordinates. This will
typically be created using |
draw_quantiles |
If |
trim |
If |
scale |
if "area" (default), all violins have the same area (before trimming the tails). If "count", areas are scaled proportionally to the number of observations. If "width", all violins have the same maximum width. |
A ggplot2::Geom object.
Not all arguments apply to all patterns.
pattern
Pattern name string e.g. 'stripe' (default), 'crosshatch', 'point', 'circle', 'none'
pattern_alpha
Alpha transparency for pattern. default: 1
pattern_angle
Orientation of the pattern in degrees. default: 30
pattern_aspect_ratio
Aspect ratio adjustment.
pattern_colour
Colour used for strokes and points. default: 'black'
pattern_density
Approximate fill fraction of the pattern. Usually in range [0, 1], but can be higher. default: 0.2
pattern_filename
Image filename/URL.
pattern_fill
Fill colour. default: 'grey80'
pattern_fill2
Second fill colour. default: '#4169E1'
pattern_filter
(Image scaling) filter. default: 'lanczos'
pattern_frequency
Frequency. default: 0.1
pattern_gravity
Image placement. default: 'center'
pattern_grid
Pattern grid type. default: 'square'
pattern_key_scale_factor
Scale factor for pattern in legend. default: 1
pattern_linetype
Stroke linetype. default: 1
pattern_option_1
Generic user value for custom patterns.
pattern_option_2
Generic user value for custom patterns.
pattern_option_3
Generic user value for custom patterns.
pattern_option_4
Generic user value for custom patterns.
pattern_option_5
Generic user value for custom patterns.
pattern_orientation
'vertical', 'horizontal', or 'radial'. default: 'vertical'
pattern_res
Pattern resolution (pixels per inch).
pattern_rot
Rotation angle (shape within pattern). default: 0
pattern_scale
Scale. default: 1
pattern_shape
Plotting shape. default: 1
pattern_size
Stroke line width. default: 1
pattern_spacing
Spacing of the pattern as a fraction of the plot size. default: 0.05
pattern_type
Generic control option
pattern_subtype
Generic control option
pattern_xoffset
Offset the origin of the pattern. Range [0, 1]. default: 0. Use this to slightly shift the origin of the pattern. For most patterns, the user should limit the offset value to be less than the pattern spacing.
pattern_yoffset
Offset the origin of the pattern. Range [0, 1]. default: 0. Use this to slightly shift the origin of the pattern. For most patterns, the user should limit the offset value to be less than the pattern spacing.
if (require("ggplot2")) { # 'stripe' pattern example df <- data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1)) gg <- ggplot(df) + geom_col_pattern( aes(level, outcome, pattern_fill = level), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + theme(legend.position = 'none') + labs( title = "ggpattern::geom_col_pattern()", subtitle = "pattern = 'stripe'" ) plot(gg) # 'pch' pattern example gg <- ggplot(mtcars, aes(as.factor(cyl), mpg)) + geom_violin_pattern(aes(fill = as.factor(cyl), pattern_shape = as.factor(cyl)), pattern = 'pch', pattern_density = 0.3, pattern_angle = 0, colour = 'black' ) + theme_bw(18) + theme(legend.position = 'none') + labs( title = "ggpattern::geom_violin_pattern()", subtitle = "pattern = 'pch'" ) plot(gg) # 'polygon_tiling' pattern example gg <- ggplot(mtcars) + geom_density_pattern( aes( x = mpg, pattern_fill = as.factor(cyl), pattern_type = as.factor(cyl) ), pattern = 'polygon_tiling', pattern_key_scale_factor = 1.2 ) + scale_pattern_type_manual(values = c("hexagonal", "rhombille", "pythagorean")) + theme_bw(18) + theme(legend.key.size = unit(2, 'cm')) + labs( title = "ggpattern::geom_density_pattern()", subtitle = "pattern = 'polygon_tiling'" ) plot(gg) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.