Title: | 'ggplot2' Pattern Geoms |
---|---|
Description: | Provides 'ggplot2' geoms filled with various patterns. Includes a patterned version of every 'ggplot2' geom that has a region that can be filled with a pattern. Provides a suite of 'ggplot2' aesthetics and scales for controlling pattern appearances. Supports over a dozen builtin patterns (every pattern implemented by 'gridpattern') as well as allowing custom user-defined patterns. |
Authors: | Mike FC [aut], Trevor L. Davis [aut, cre] , ggplot2 authors [aut] |
Maintainer: | Trevor L. Davis <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.1 |
Built: | 2024-11-01 04:56:51 UTC |
Source: | https://github.com/coolbutuseless/ggpattern |
polygon_df
object from the given coordinatescode using polygon_df
should not assume that the first and last point
within each id are the same. i.e. they may have to manulaly set a final
point equal to the initial point if that is what their graphics system
desires
create_polygon_df(x, y, id = 1L)
create_polygon_df(x, y, id = 1L)
x , y
|
coordinates of polygon. not necessarily closed. |
id |
a numeric vector used to separate locations in x,y into multiple polygons |
data.frame with x, y, id columns.
df <- create_polygon_df(x = c(0, 0, 1, 1), y = c(0, 1, 1, 0)) is_polygon_df(df)
df <- create_polygon_df(x = c(0, 0, 1, 1), y = c(0, 1, 1, 0)) is_polygon_df(df)
Each geom has an associated function that draws the key when the geom needs
to be displayed in a legend. These functions are called draw_key_*()
, where
*
stands for the name of the respective key glyph. The key glyphs can be
customized for individual geoms by providing a geom with the key_glyph
argument (see layer()
or examples below.)
draw_key_polygon_pattern(data, params, size, aspect_ratio = get_aspect_ratio()) draw_key_boxplot_pattern(data, params, size, aspect_ratio = get_aspect_ratio()) draw_key_crossbar_pattern( data, params, size, aspect_ratio = get_aspect_ratio() )
draw_key_polygon_pattern(data, params, size, aspect_ratio = get_aspect_ratio()) draw_key_boxplot_pattern(data, params, size, aspect_ratio = get_aspect_ratio()) draw_key_crossbar_pattern( data, params, size, aspect_ratio = get_aspect_ratio() )
data |
A single row data frame containing the scaled aesthetics to display in this key |
params |
A list of additional parameters supplied to the geom. |
size |
Width and height of key in mm. |
aspect_ratio |
the geom's best guess at what the aspect ratio might be. |
A grid grob.
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', key_glyph = draw_key_polygon_pattern ) + theme_bw(18) + theme(legend.position = 'none') + labs( title = "ggpattern::geom_col_pattern()", subtitle = "pattern = 'stripe'" ) plot(gg) }
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', key_glyph = draw_key_polygon_pattern ) + theme_bw(18) + theme(legend.position = 'none') + labs( title = "ggpattern::geom_col_pattern()", subtitle = "pattern = 'stripe'" ) plot(gg) }
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", ..., just = 0.5, width = NULL, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) geom_bin_2d_pattern( mapping = NULL, data = NULL, stat = "bin2d", position = "identity", ..., na.rm = FALSE, 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", ..., outliers = TRUE, 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, staplewidth = 0, varwidth = FALSE, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) geom_col_pattern( mapping = NULL, data = NULL, position = "stack", ..., just = 0.5, 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 = "align", 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, outline.type = "upper" ) 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_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, bounds = c(-Inf, Inf), scale = "area", na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )
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", ..., just = 0.5, width = NULL, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) geom_bin_2d_pattern( mapping = NULL, data = NULL, stat = "bin2d", position = "identity", ..., na.rm = FALSE, 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", ..., outliers = TRUE, 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, staplewidth = 0, varwidth = FALSE, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) geom_col_pattern( mapping = NULL, data = NULL, position = "stack", ..., just = 0.5, 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 = "align", 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, outline.type = "upper" ) 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_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, bounds = c(-Inf, Inf), 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.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
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 |
just |
Adjustment for column placement. Set to |
width |
Bar width. By default, set to 90% of the |
orientation |
The orientation of the layer. The default ( |
outliers |
Whether to display ( |
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. |
notch |
If |
notchwidth |
For a notched box plot, width of the notch relative to
the body (defaults to |
staplewidth |
The relative width of staples to the width of the box. Staples mark the ends of the whiskers with a line. |
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; |
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. |
bins |
Number of bins. Overridden by |
rule |
Either |
map |
Data frame that contains the map coordinates. This will
typically be created using |
draw_quantiles |
If |
trim |
If |
bounds |
Known lower and upper bounds for estimated data. Default
|
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 (or grid::pattern()
/gradient fill). default: 'grey80'
pattern_fill2
Second fill colour (or grid::pattern()
/gradient fill). 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) }
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) }
Geom ggproto objects that could be extended to create a new geom.
These data/functions are Defunct in this release of ggpattern.
For magick_filter_names
use magick::filter_types()
instead.
For magick_gravity_names
use magick::gravity_types()
instead.
For magick_pattern_intensity_names
use gridpattern::names_magick_intensity
.
For magick_pattern_names
use gridpattern::names_magick
.
For magick_pattern_stripe_names
use gridpattern::names_magick_stripe
.
For placeholder_names
use gridpattern::names_placeholder
.
calculate_bbox_polygon_df(...) convert_img_to_array(...) convert_polygon_df_to_alpha_channel(...) convert_polygon_df_to_polygon_grob(...) convert_polygon_df_to_polygon_sf(...) convert_polygon_sf_to_polygon_df(...) create_gradient_img(...) fetch_placeholder_img(...) fill_area_with_img(...) rotate_polygon_df(...)
calculate_bbox_polygon_df(...) convert_img_to_array(...) convert_polygon_df_to_alpha_channel(...) convert_polygon_df_to_polygon_grob(...) convert_polygon_df_to_polygon_sf(...) convert_polygon_sf_to_polygon_df(...) create_gradient_img(...) fetch_placeholder_img(...) fill_area_with_img(...) rotate_polygon_df(...)
... |
Ignored |
Test if object is polygon_df or NULL
is_polygon_df(x)
is_polygon_df(x)
x |
object |
TRUE if object is polygon_df or NULL
df <- create_polygon_df(x = c(0, 0, 1, 1), y = c(0, 1, 1, 0)) is_polygon_df(df)
df <- create_polygon_df(x = c(0, 0, 1, 1), y = c(0, 1, 1, 0)) is_polygon_df(df)
Scales for continuous pattern aesthetics
scale_pattern_angle_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0, 90), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_angle_discrete(..., range = c(0, 90)) scale_pattern_density_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0, 0.5), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_density_discrete(..., range = c(0, 0.5)) scale_pattern_spacing_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.01, 0.1), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_spacing_discrete(..., range = c(0.01, 0.1)) scale_pattern_xoffset_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.01, 0.1), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_xoffset_discrete(..., range = c(0.01, 0.1)) scale_pattern_yoffset_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.01, 0.1), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_yoffset_discrete(..., range = c(0.01, 0.1)) scale_pattern_aspect_ratio_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.5, 2), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_aspect_ratio_discrete(..., range = c(0.5, 2)) scale_pattern_key_scale_factor_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.5, 2), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_key_scale_factor_discrete(..., range = c(0.5, 2)) scale_pattern_scale_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.5, 2), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_scale_discrete(..., range = c(0.5, 2)) scale_pattern_phase_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_phase_discrete(..., range = NULL) scale_pattern_frequency_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_frequency_discrete(..., range = NULL) scale_pattern_res_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_res_discrete(..., range = NULL) scale_pattern_rot_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0, 360), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_rot_discrete(..., range = c(0, 360))
scale_pattern_angle_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0, 90), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_angle_discrete(..., range = c(0, 90)) scale_pattern_density_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0, 0.5), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_density_discrete(..., range = c(0, 0.5)) scale_pattern_spacing_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.01, 0.1), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_spacing_discrete(..., range = c(0.01, 0.1)) scale_pattern_xoffset_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.01, 0.1), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_xoffset_discrete(..., range = c(0.01, 0.1)) scale_pattern_yoffset_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.01, 0.1), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_yoffset_discrete(..., range = c(0.01, 0.1)) scale_pattern_aspect_ratio_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.5, 2), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_aspect_ratio_discrete(..., range = c(0.5, 2)) scale_pattern_key_scale_factor_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.5, 2), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_key_scale_factor_discrete(..., range = c(0.5, 2)) scale_pattern_scale_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0.5, 2), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_scale_discrete(..., range = c(0.5, 2)) scale_pattern_phase_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_phase_discrete(..., range = NULL) scale_pattern_frequency_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_frequency_discrete(..., range = NULL) scale_pattern_res_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_res_discrete(..., range = NULL) scale_pattern_rot_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(0, 360), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_rot_discrete(..., range = c(0, 360))
name , breaks , labels , limits , range , trans , guide , ... , transform
|
See
|
A ggplot2::Scale object.
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_density = outcome), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + theme(legend.position = 'none') + scale_pattern_density_continuous(range = c(0.1, 0.6)) + labs( title = 'ggpattern::geom_col_pattern()', subtitle = 'pattern = \'stripe\'' ) plot(gg) }
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_density = outcome), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + theme(legend.position = 'none') + scale_pattern_density_continuous(range = c(0.1, 0.6)) + labs( title = 'ggpattern::geom_col_pattern()', subtitle = 'pattern = \'stripe\'' ) plot(gg) }
Scales for discrete pattern aesthetics
scale_pattern_type_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_type_discrete(..., choices = NULL, guide = "legend") scale_pattern_subtype_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_subtype_discrete(..., choices = NULL, guide = "legend") scale_pattern_filename_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_filename_discrete(..., choices = NULL, guide = "legend") scale_pattern_filter_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("lanczos", "box", "spline", "cubic"), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_filter_discrete( ..., choices = c("lanczos", "box", "spline", "cubic"), guide = "legend" ) scale_pattern_gravity_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("center", "north", "south", "east", "west", "northeast", "northwest", "southeast", "southwest"), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_gravity_discrete( ..., choices = c("center", "north", "south", "east", "west", "northeast", "northwest", "southeast", "southwest"), guide = "legend" ) scale_pattern_orientation_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("horizontal", "vertical", "radial"), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_orientation_discrete( ..., choices = c("horizontal", "vertical", "radial"), guide = "legend" ) scale_pattern_grid_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("square", "hex"), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_grid_discrete( ..., choices = c("square", "hex"), guide = "legend" ) scale_pattern_units_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("snpc", "cm", "inches"), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_units_discrete( ..., choices = c("snpc", "cm", "inches"), guide = "legend" ) scale_pattern_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("stripe", "crosshatch", "circle"), trans = deprecated(), guide = "legend", ..., transform = "identity", na.value = "none" ) scale_pattern_discrete( ..., choices = c("stripe", "crosshatch", "circle"), guide = "legend", na.value = "none" )
scale_pattern_type_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_type_discrete(..., choices = NULL, guide = "legend") scale_pattern_subtype_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_subtype_discrete(..., choices = NULL, guide = "legend") scale_pattern_filename_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = NULL, trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_filename_discrete(..., choices = NULL, guide = "legend") scale_pattern_filter_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("lanczos", "box", "spline", "cubic"), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_filter_discrete( ..., choices = c("lanczos", "box", "spline", "cubic"), guide = "legend" ) scale_pattern_gravity_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("center", "north", "south", "east", "west", "northeast", "northwest", "southeast", "southwest"), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_gravity_discrete( ..., choices = c("center", "north", "south", "east", "west", "northeast", "northwest", "southeast", "southwest"), guide = "legend" ) scale_pattern_orientation_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("horizontal", "vertical", "radial"), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_orientation_discrete( ..., choices = c("horizontal", "vertical", "radial"), guide = "legend" ) scale_pattern_grid_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("square", "hex"), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_grid_discrete( ..., choices = c("square", "hex"), guide = "legend" ) scale_pattern_units_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("snpc", "cm", "inches"), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_units_discrete( ..., choices = c("snpc", "cm", "inches"), guide = "legend" ) scale_pattern_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, choices = c("stripe", "crosshatch", "circle"), trans = deprecated(), guide = "legend", ..., transform = "identity", na.value = "none" ) scale_pattern_discrete( ..., choices = c("stripe", "crosshatch", "circle"), guide = "legend", na.value = "none" )
name , breaks , labels , limits , trans , guide , ... , transform , na.value
|
See
|
choices |
vector of values to choose from. |
A ggplot2::Scale object.
if (require('ggplot2')) { 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_discrete(choices = gridpattern::names_polygon_tiling) + theme_bw(18) + theme(legend.key.size = unit(2, 'cm')) + labs( title = 'ggpattern::geom_density_pattern()', subtitle = 'pattern = \'polygon_tiling\'' ) plot(gg) }
if (require('ggplot2')) { 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_discrete(choices = gridpattern::names_polygon_tiling) + theme_bw(18) + theme(legend.key.size = unit(2, 'cm')) + labs( title = 'ggpattern::geom_density_pattern()', subtitle = 'pattern = \'polygon_tiling\'' ) plot(gg) }
See ggplot2::scale_alpha()
for details.
scale_pattern_alpha_continuous(..., range = c(0.1, 1)) scale_pattern_alpha(..., range = c(0.1, 1)) scale_pattern_alpha_discrete(...) scale_pattern_alpha_ordinal(..., range = c(0.1, 1))
scale_pattern_alpha_continuous(..., range = c(0.1, 1)) scale_pattern_alpha(..., range = c(0.1, 1)) scale_pattern_alpha_discrete(...) scale_pattern_alpha_ordinal(..., range = c(0.1, 1))
... |
Other arguments passed on to |
range |
Output range of alpha values. Must lie between 0 and 1. |
A ggplot2::Scale object.
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_alpha = outcome), pattern_density = 0.6, pattern_size = 1.5, pattern = 'stripe', fill = 'white', colour = 'black', size = 1.5 ) + theme_bw(18) + theme(legend.position = 'none') + scale_pattern_alpha() + labs( title = "ggpattern::geom_col_pattern()", subtitle = "pattern = 'stripe'" ) plot(gg) }
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_alpha = outcome), pattern_density = 0.6, pattern_size = 1.5, pattern = 'stripe', fill = 'white', colour = 'black', size = 1.5 ) + theme_bw(18) + theme(legend.position = 'none') + scale_pattern_alpha() + labs( title = "ggpattern::geom_col_pattern()", subtitle = "pattern = 'stripe'" ) plot(gg) }
The brewer
scales provides sequential, diverging and qualitative
colour schemes from ColorBrewer. These are particularly well suited to
display discrete values on a map. See https://colorbrewer2.org for
more information.
scale_pattern_colour_brewer( ..., type = "seq", palette = 1, direction = 1, aesthetics = "pattern_colour" ) scale_pattern_fill_brewer( ..., type = "seq", palette = 1, direction = 1, aesthetics = "pattern_fill" ) scale_pattern_fill2_brewer( ..., type = "seq", palette = 1, direction = 1, aesthetics = "pattern_fill2" ) scale_pattern_colour_distiller( ..., type = "seq", palette = 1, direction = -1, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_colour"), aesthetics = "pattern_colour" ) scale_pattern_fill_distiller( ..., type = "seq", palette = 1, direction = -1, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill"), aesthetics = "pattern_fill" ) scale_pattern_fill2_distiller( ..., type = "seq", palette = 1, direction = -1, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill2"), aesthetics = "pattern_fill2" )
scale_pattern_colour_brewer( ..., type = "seq", palette = 1, direction = 1, aesthetics = "pattern_colour" ) scale_pattern_fill_brewer( ..., type = "seq", palette = 1, direction = 1, aesthetics = "pattern_fill" ) scale_pattern_fill2_brewer( ..., type = "seq", palette = 1, direction = 1, aesthetics = "pattern_fill2" ) scale_pattern_colour_distiller( ..., type = "seq", palette = 1, direction = -1, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_colour"), aesthetics = "pattern_colour" ) scale_pattern_fill_distiller( ..., type = "seq", palette = 1, direction = -1, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill"), aesthetics = "pattern_fill" ) scale_pattern_fill2_distiller( ..., type = "seq", palette = 1, direction = -1, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill2"), aesthetics = "pattern_fill2" )
... |
Other arguments passed on to |
palette |
If a string, will use that named palette. If a number, will index into
the list of palettes of appropriate |
direction , type , aesthetics , values , space , na.value , guide
|
See |
The brewer
scales were carefully designed and tested on discrete data.
They were not designed to be extended to continuous data, but results often
look good. Your mileage may vary.
A ggplot2::Scale object.
The following palettes are available for use with these scales:
BrBG, PiYG, PRGn, PuOr, RdBu, RdGy, RdYlBu, RdYlGn, Spectral
Accent, Dark2, Paired, Pastel1, Pastel2, Set1, Set2, Set3
Blues, BuGn, BuPu, GnBu, Greens, Greys, Oranges, OrRd, PuBu, PuBuGn, PuRd, Purples, RdPu, Reds, YlGn, YlGnBu, YlOrBr, YlOrRd
Modify the palette through the palette
arguement.
The distiller
scales extend brewer to continuous scales by smoothly
interpolating 7 colours from any palette to a continuous scale. The fermenter
scales provide binned versions of the brewer scales.
if (require("ggplot2")) { df <- data.frame(level = c("a", "b", "c", "d"), outcome = c(2.3, 1.9, 3.2, 1)) # discrete 'brewer' palette gg <- ggplot(df) + geom_col_pattern( aes(level, outcome, pattern_fill = level), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_brewer() plot(gg) # continuous 'distiller' palette gg <- ggplot(df) + geom_col_pattern( aes(level, outcome, pattern_fill = outcome), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_distiller() plot(gg) }
if (require("ggplot2")) { df <- data.frame(level = c("a", "b", "c", "d"), outcome = c(2.3, 1.9, 3.2, 1)) # discrete 'brewer' palette gg <- ggplot(df) + geom_col_pattern( aes(level, outcome, pattern_fill = level), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_brewer() plot(gg) # continuous 'distiller' palette gg <- ggplot(df) + geom_col_pattern( aes(level, outcome, pattern_fill = outcome), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_distiller() plot(gg) }
See ggplot2::scale_colour_continuous()
for more information
scale_pattern_colour_continuous( ..., type = getOption("ggplot2.continuous.colour", default = "gradient") ) scale_pattern_fill_continuous( ..., type = getOption("ggplot2.continuous.fill", default = "gradient") ) scale_pattern_fill2_continuous( ..., type = getOption("ggplot2.continuous.fill", default = "gradient") )
scale_pattern_colour_continuous( ..., type = getOption("ggplot2.continuous.colour", default = "gradient") ) scale_pattern_fill_continuous( ..., type = getOption("ggplot2.continuous.fill", default = "gradient") ) scale_pattern_fill2_continuous( ..., type = getOption("ggplot2.continuous.fill", default = "gradient") )
... |
Additional parameters passed on to the scale type |
type |
One of "gradient" (the default) or "viridis" indicating the colour scale to use |
A ggplot2::Scale object.
if (require("ggplot2")) { 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 = outcome), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_continuous() plot(gg) }
if (require("ggplot2")) { 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 = outcome), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_continuous() plot(gg) }
See ggplot2::scale_colour_gradient()
for more information
scale_pattern_colour_gradient( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_colour"), aesthetics = "pattern_colour" ) scale_pattern_fill_gradient( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill"), aesthetics = "pattern_fill" ) scale_pattern_fill2_gradient( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill2"), aesthetics = "pattern_fill2" ) scale_pattern_colour_gradient2( ..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_colour"), aesthetics = "pattern_colour" ) scale_pattern_fill_gradient2( ..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill"), aesthetics = "pattern_fill" ) scale_pattern_fill2_gradient2( ..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill2"), aesthetics = "pattern_fill2" ) scale_pattern_colour_gradientn( ..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_colour"), aesthetics = "pattern_colour", colors ) scale_pattern_fill_gradientn( ..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill"), aesthetics = "pattern_fill", colors ) scale_pattern_fill2_gradientn( ..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill2"), aesthetics = "pattern_fill2", colors )
scale_pattern_colour_gradient( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_colour"), aesthetics = "pattern_colour" ) scale_pattern_fill_gradient( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill"), aesthetics = "pattern_fill" ) scale_pattern_fill2_gradient( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill2"), aesthetics = "pattern_fill2" ) scale_pattern_colour_gradient2( ..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_colour"), aesthetics = "pattern_colour" ) scale_pattern_fill_gradient2( ..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill"), aesthetics = "pattern_fill" ) scale_pattern_fill2_gradient2( ..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill2"), aesthetics = "pattern_fill2" ) scale_pattern_colour_gradientn( ..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_colour"), aesthetics = "pattern_colour", colors ) scale_pattern_fill_gradientn( ..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill"), aesthetics = "pattern_fill", colors ) scale_pattern_fill2_gradientn( ..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill2"), aesthetics = "pattern_fill2", colors )
low , high
|
Colours for low and high ends of the gradient. |
space , ... , na.value , aesthetics
|
See |
guide |
Type of legend. Use |
mid |
colour for mid point |
midpoint |
The midpoint (in data value) of the diverging scale. Defaults to 0. |
colours , colors
|
Vector of colours to use for n-colour gradient. |
values |
if colours should not be evenly positioned along the gradient
this vector gives the position (between 0 and 1) for each colour in the
|
scale_*_gradient
creates a two colour gradient (low-high),
scale_*_gradient2
creates a diverging colour gradient (low-mid-high),
scale_*_gradientn
creates a n-colour gradient.
A ggplot2::Scale object.
if (require("ggplot2")) { 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 = outcome), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_gradient() plot(gg) }
if (require("ggplot2")) { 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 = outcome), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_gradient() plot(gg) }
Based on gray.colors()
. This is black and white equivalent
of scale_pattern_colour_gradient()
.
scale_pattern_colour_grey( ..., start = 0.2, end = 0.8, na.value = "red", aesthetics = "pattern_colour" ) scale_pattern_fill_grey( ..., start = 0.2, end = 0.8, na.value = "red", aesthetics = "pattern_fill" ) scale_pattern_fill2_grey( ..., start = 0.2, end = 0.8, na.value = "red", aesthetics = "pattern_fill2" )
scale_pattern_colour_grey( ..., start = 0.2, end = 0.8, na.value = "red", aesthetics = "pattern_colour" ) scale_pattern_fill_grey( ..., start = 0.2, end = 0.8, na.value = "red", aesthetics = "pattern_fill" ) scale_pattern_fill2_grey( ..., start = 0.2, end = 0.8, na.value = "red", aesthetics = "pattern_fill2" )
... , start , end , na.value , aesthetics
|
See
|
A ggplot2::Scale object.
if (require("ggplot2")) { 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) + scale_pattern_fill_grey() plot(gg) }
if (require("ggplot2")) { 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) + scale_pattern_fill_grey() plot(gg) }
This is the default colour scale for categorical variables. It maps each level to an evenly spaced hue on the colour wheel. It does not generate colour-blind safe palettes.
scale_pattern_colour_hue( ..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "pattern_colour" ) scale_pattern_fill_hue( ..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "pattern_fill" ) scale_pattern_fill2_hue( ..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "pattern_fill2" )
scale_pattern_colour_hue( ..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "pattern_colour" ) scale_pattern_fill_hue( ..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "pattern_fill" ) scale_pattern_fill2_hue( ..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "pattern_fill2" )
h , c , l , h.start , direction , ...
|
See |
na.value |
Colour to use for missing values |
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
A ggplot2::Scale object.
if (require("ggplot2")) { 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) + scale_pattern_fill_hue() plot(gg) }
if (require("ggplot2")) { 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) + scale_pattern_fill_hue() plot(gg) }
The viridis
scales provide colour maps that are perceptually uniform in both
colour and black-and-white. They are also designed to be perceived by viewers
with common forms of colour blindness. See also
https://bids.github.io/colormap/.
scale_pattern_colour_viridis_d( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", aesthetics = "pattern_colour" ) scale_pattern_fill_viridis_d( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", aesthetics = "pattern_fill" ) scale_pattern_fill2_viridis_d( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", aesthetics = "pattern_fill2" ) scale_pattern_colour_viridis_c( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_colour"), aesthetics = "pattern_colour" ) scale_pattern_fill_viridis_c( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill"), aesthetics = "pattern_fill" ) scale_pattern_fill2_viridis_c( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill2"), aesthetics = "pattern_fill2" )
scale_pattern_colour_viridis_d( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", aesthetics = "pattern_colour" ) scale_pattern_fill_viridis_d( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", aesthetics = "pattern_fill" ) scale_pattern_fill2_viridis_d( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", aesthetics = "pattern_fill2" ) scale_pattern_colour_viridis_c( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_colour"), aesthetics = "pattern_colour" ) scale_pattern_fill_viridis_c( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill"), aesthetics = "pattern_fill" ) scale_pattern_fill2_viridis_c( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = guide_colourbar(available_aes = "pattern_fill2"), aesthetics = "pattern_fill2" )
... |
Other arguments passed on to |
begin , end , alpha , direction , option , values , space , na.value , guide
|
See |
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
A ggplot2::Scale object.
if (require("ggplot2")) { df <- data.frame(level = c("a", "b", "c", "d"), outcome = c(2.3, 1.9, 3.2, 1)) # discrete 'viridis' palette gg <- ggplot(df) + geom_col_pattern( aes(level, outcome, pattern_fill = level), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_viridis_d() plot(gg) # continuous 'viridis' palette gg <- ggplot(df) + geom_col_pattern( aes(level, outcome, pattern_fill = outcome), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_viridis_c() plot(gg) }
if (require("ggplot2")) { df <- data.frame(level = c("a", "b", "c", "d"), outcome = c(2.3, 1.9, 3.2, 1)) # discrete 'viridis' palette gg <- ggplot(df) + geom_col_pattern( aes(level, outcome, pattern_fill = level), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_viridis_d() plot(gg) # continuous 'viridis' palette gg <- ggplot(df) + geom_col_pattern( aes(level, outcome, pattern_fill = outcome), pattern = 'stripe', fill = 'white', colour = 'black' ) + theme_bw(18) + scale_pattern_fill_viridis_c() plot(gg) }
Use values without scaling
scale_pattern_type_identity(..., guide = "none") scale_pattern_subtype_identity(..., guide = "none") scale_pattern_angle_identity(..., guide = "none") scale_pattern_density_identity(..., guide = "none") scale_pattern_spacing_identity(..., guide = "none") scale_pattern_xoffset_identity(..., guide = "none") scale_pattern_yoffset_identity(..., guide = "none") scale_pattern_alpha_identity(..., guide = "none") scale_pattern_linetype_identity(..., guide = "none") scale_pattern_size_identity(..., guide = "none") scale_pattern_shape_identity(..., guide = "none") scale_pattern_colour_identity(..., guide = "none") scale_pattern_fill_identity(..., guide = "none") scale_pattern_fill2_identity(..., guide = "none") scale_pattern_aspect_ratio_identity(..., guide = "none") scale_pattern_key_scale_factor_identity(..., guide = "none") scale_pattern_filename_identity(..., guide = "none") scale_pattern_filter_identity(..., guide = "none") scale_pattern_gravity_identity(..., guide = "none") scale_pattern_scale_identity(..., guide = "none") scale_pattern_orientation_identity(..., guide = "none") scale_pattern_phase_identity(..., guide = "none") scale_pattern_frequency_identity(..., guide = "none") scale_pattern_grid_identity(..., guide = "none") scale_pattern_res_identity(..., guide = "none") scale_pattern_rot_identity(..., guide = "none") scale_pattern_units_identity(..., guide = "none") scale_pattern_identity(..., guide = "none")
scale_pattern_type_identity(..., guide = "none") scale_pattern_subtype_identity(..., guide = "none") scale_pattern_angle_identity(..., guide = "none") scale_pattern_density_identity(..., guide = "none") scale_pattern_spacing_identity(..., guide = "none") scale_pattern_xoffset_identity(..., guide = "none") scale_pattern_yoffset_identity(..., guide = "none") scale_pattern_alpha_identity(..., guide = "none") scale_pattern_linetype_identity(..., guide = "none") scale_pattern_size_identity(..., guide = "none") scale_pattern_shape_identity(..., guide = "none") scale_pattern_colour_identity(..., guide = "none") scale_pattern_fill_identity(..., guide = "none") scale_pattern_fill2_identity(..., guide = "none") scale_pattern_aspect_ratio_identity(..., guide = "none") scale_pattern_key_scale_factor_identity(..., guide = "none") scale_pattern_filename_identity(..., guide = "none") scale_pattern_filter_identity(..., guide = "none") scale_pattern_gravity_identity(..., guide = "none") scale_pattern_scale_identity(..., guide = "none") scale_pattern_orientation_identity(..., guide = "none") scale_pattern_phase_identity(..., guide = "none") scale_pattern_frequency_identity(..., guide = "none") scale_pattern_grid_identity(..., guide = "none") scale_pattern_res_identity(..., guide = "none") scale_pattern_rot_identity(..., guide = "none") scale_pattern_units_identity(..., guide = "none") scale_pattern_identity(..., guide = "none")
... , guide
|
See |
A ggplot2::Scale object.
if (require('ggplot2')) { df <- data.frame(outcome = c(2.3, 1.9, 3.2, 1), pattern_type = sample(gridpattern::names_polygon_tiling, 4)) gg <- ggplot(df) + geom_col_pattern( aes(pattern_type, outcome, pattern_fill = pattern_type, pattern_type = pattern_type), colour = 'black', pattern = 'polygon_tiling', pattern_key_scale_factor = 1.2 ) + scale_pattern_type_identity() + theme_bw(18) + theme(legend.position = 'none') + labs( x = 'level', title = 'ggpattern::geom_col_pattern()', subtitle = 'pattern = \'polygon_tiling\'' ) plot(gg) }
if (require('ggplot2')) { df <- data.frame(outcome = c(2.3, 1.9, 3.2, 1), pattern_type = sample(gridpattern::names_polygon_tiling, 4)) gg <- ggplot(df) + geom_col_pattern( aes(pattern_type, outcome, pattern_fill = pattern_type, pattern_type = pattern_type), colour = 'black', pattern = 'polygon_tiling', pattern_key_scale_factor = 1.2 ) + scale_pattern_type_identity() + theme_bw(18) + theme(legend.position = 'none') + labs( x = 'level', title = 'ggpattern::geom_col_pattern()', subtitle = 'pattern = \'polygon_tiling\'' ) plot(gg) }
Default line types based on a set supplied by Richard Pearson, University of Manchester. Continuous values can not be mapped to line types.
scale_pattern_linetype(..., na.value = "blank") scale_pattern_linetype_continuous(...) scale_pattern_linetype_discrete(..., na.value = "blank")
scale_pattern_linetype(..., na.value = "blank") scale_pattern_linetype_continuous(...) scale_pattern_linetype_discrete(..., na.value = "blank")
... |
see |
na.value |
The linetype to use for |
A ggplot2::Scale object.
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_linetype = level), pattern_density = 0.6, pattern_size = 1.5, pattern = 'stripe', fill = 'white', colour = 'black', size = 1.5 ) + theme_bw(18) + theme(legend.position = 'none') + scale_pattern_linetype() + labs( title = "ggpattern::geom_col_pattern()", subtitle = "pattern = 'stripe'" ) plot(gg) }
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_linetype = level), pattern_density = 0.6, pattern_size = 1.5, pattern = 'stripe', fill = 'white', colour = 'black', size = 1.5 ) + theme_bw(18) + theme(legend.position = 'none') + scale_pattern_linetype() + labs( title = "ggpattern::geom_col_pattern()", subtitle = "pattern = 'stripe'" ) plot(gg) }
Create your own discrete scale
scale_pattern_type_manual(..., values, breaks = waiver()) scale_pattern_subtype_manual(..., values, breaks = waiver()) scale_pattern_angle_manual(..., values, breaks = waiver()) scale_pattern_density_manual(..., values, breaks = waiver()) scale_pattern_spacing_manual(..., values, breaks = waiver()) scale_pattern_xoffset_manual(..., values, breaks = waiver()) scale_pattern_yoffset_manual(..., values, breaks = waiver()) scale_pattern_alpha_manual(..., values, breaks = waiver()) scale_pattern_linetype_manual(..., values, breaks = waiver()) scale_pattern_size_manual(..., values, breaks = waiver()) scale_pattern_shape_manual(..., values, breaks = waiver()) scale_pattern_colour_manual(..., values, breaks = waiver()) scale_pattern_fill_manual(..., values, breaks = waiver()) scale_pattern_fill2_manual(..., values, breaks = waiver()) scale_pattern_aspect_ratio_manual(..., values, breaks = waiver()) scale_pattern_key_scale_factor_manual(..., values, breaks = waiver()) scale_pattern_filename_manual(..., values, breaks = waiver()) scale_pattern_filter_manual(..., values, breaks = waiver()) scale_pattern_gravity_manual(..., values, breaks = waiver()) scale_pattern_scale_manual(..., values, breaks = waiver()) scale_pattern_orientation_manual(..., values, breaks = waiver()) scale_pattern_phase_manual(..., values, breaks = waiver()) scale_pattern_frequency_manual(..., values, breaks = waiver()) scale_pattern_grid_manual(..., values, breaks = waiver()) scale_pattern_res_manual(..., values, breaks = waiver()) scale_pattern_rot_manual(..., values, breaks = waiver()) scale_pattern_units_manual(..., values, breaks = waiver()) scale_pattern_manual(..., values, breaks = waiver(), na.value = "none")
scale_pattern_type_manual(..., values, breaks = waiver()) scale_pattern_subtype_manual(..., values, breaks = waiver()) scale_pattern_angle_manual(..., values, breaks = waiver()) scale_pattern_density_manual(..., values, breaks = waiver()) scale_pattern_spacing_manual(..., values, breaks = waiver()) scale_pattern_xoffset_manual(..., values, breaks = waiver()) scale_pattern_yoffset_manual(..., values, breaks = waiver()) scale_pattern_alpha_manual(..., values, breaks = waiver()) scale_pattern_linetype_manual(..., values, breaks = waiver()) scale_pattern_size_manual(..., values, breaks = waiver()) scale_pattern_shape_manual(..., values, breaks = waiver()) scale_pattern_colour_manual(..., values, breaks = waiver()) scale_pattern_fill_manual(..., values, breaks = waiver()) scale_pattern_fill2_manual(..., values, breaks = waiver()) scale_pattern_aspect_ratio_manual(..., values, breaks = waiver()) scale_pattern_key_scale_factor_manual(..., values, breaks = waiver()) scale_pattern_filename_manual(..., values, breaks = waiver()) scale_pattern_filter_manual(..., values, breaks = waiver()) scale_pattern_gravity_manual(..., values, breaks = waiver()) scale_pattern_scale_manual(..., values, breaks = waiver()) scale_pattern_orientation_manual(..., values, breaks = waiver()) scale_pattern_phase_manual(..., values, breaks = waiver()) scale_pattern_frequency_manual(..., values, breaks = waiver()) scale_pattern_grid_manual(..., values, breaks = waiver()) scale_pattern_res_manual(..., values, breaks = waiver()) scale_pattern_rot_manual(..., values, breaks = waiver()) scale_pattern_units_manual(..., values, breaks = waiver()) scale_pattern_manual(..., values, breaks = waiver(), na.value = "none")
... , values , breaks , na.value
|
See |
A ggplot2::Scale object.
if (require('ggplot2')) { 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) }
if (require('ggplot2')) { 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) }
scale_pattern_shape
maps discrete variables to six easily discernible shapes.
If you have more than six levels, you will get a warning message, and the
seventh and subsequence levels will not appear on the plot. Use
scale_pattern_shape_manual()
to supply your own values. You can not map
a continuous variable to shape unless scale_pattern_shape_binned()
is used. Still,
as shape has no inherent order, this use is not advised..
scale_pattern_shape(..., solid = TRUE) scale_pattern_shape_discrete(..., solid = TRUE) scale_pattern_shape_ordinal(...) scale_pattern_shape_continuous(...)
scale_pattern_shape(..., solid = TRUE) scale_pattern_shape_discrete(..., solid = TRUE) scale_pattern_shape_ordinal(...) scale_pattern_shape_continuous(...)
... |
other arguments passed to discrete_scale() |
solid |
Should the shapes be solid, |
Scales for area or radius
A ggplot2::Scale object.
if (require("ggplot2")) { # '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') + scale_pattern_shape() + labs( title = "ggpattern::geom_violin_pattern()", subtitle = "pattern = 'pch'" ) plot(gg) }
if (require("ggplot2")) { # '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') + scale_pattern_shape() + labs( title = "ggpattern::geom_violin_pattern()", subtitle = "pattern = 'pch'" ) plot(gg) }
Scales for area or radius
scale_pattern_size_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(1, 6), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_size( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(1, 6), trans = deprecated(), guide = "legend", ..., transform = "identity" )
scale_pattern_size_continuous( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(1, 6), trans = deprecated(), guide = "legend", ..., transform = "identity" ) scale_pattern_size( name = waiver(), breaks = waiver(), labels = waiver(), limits = NULL, range = c(1, 6), trans = deprecated(), guide = "legend", ..., transform = "identity" )
name , breaks , labels , limits , trans , guide , ... , transform
|
See |
range |
a numeric vector of length 2 that specifies the minimum and maximum size of the plotting symbol after transformation. |
A ggplot2::Scale object.
if (require("ggplot2")) { # 'circle' 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, size = outcome, pattern_size = outcome), pattern_density = 0.4, pattern_spacing = 0.3, pattern = 'circle', fill = 'white', colour = 'black' ) + theme_bw(18) + theme(legend.position = 'none') + scale_pattern_size() + labs( title = "ggpattern::geom_col_pattern()", subtitle = "pattern = 'circle'" ) plot(gg) }
if (require("ggplot2")) { # 'circle' 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, size = outcome, pattern_size = outcome), pattern_density = 0.4, pattern_spacing = 0.3, pattern = 'circle', fill = 'white', colour = 'black' ) + theme_bw(18) + theme(legend.position = 'none') + scale_pattern_size() + labs( title = "ggpattern::geom_col_pattern()", subtitle = "pattern = 'circle'" ) plot(gg) }