ggpattern 1.4.0 (development)
Breaking changes
-
Most pattern aesthetics are now unset by default (internally
NaN) so the pattern’s own default applies (falling back to gridpattern’s generic defaults) instead of ggpattern’s one-size-fits-all values. The only exception ispatternitself. The generic defaults match our previous defaults so most patterns render the same as before but this changes the default appearance of a few patterns:- “wave” now uses a frequency of
1 / pattern_spacing(previously0.1) so its lines are visibly wavy by default. - “ambient” now uses a frequency of
0.01(previously0.1). - “regular_polygon” star shapes (e.g.
"star5") now use a scale of0.5(previously1which drew them as convex polygons with twice as many vertices). - “text” now uses the shape
"X"(previously1) and a fontsize of12(previously0.5).
Set the aesthetic explicitly to restore the previous appearance. Custom patterns registered with
gridpattern::register_pattern()may now declare their own defaults for any of these aesthetics. - “wave” now uses a frequency of
Legend keys are now scaled by gridpattern (using its new numeric
legendargument) which draws the key’s pattern in a viewport larger than the key instead of us rescalingpattern_spacing,pattern_xoffset, andpattern_yoffset. All relative (“snpc”) lengths now scale together in legend keys (including those of custom patterns e.g. a “wave” amplitude or a pattern-specific spacing default).pattern_key_scale_factorstill multiplies the spacing and offsets of absolute lengths (e.g. “cm”pattern_units) and “npc”pattern_unitsare now scaled like “snpc” units. Legend keys look essentially the same as before.A numeric
pattern_shapeis no longer silently replaced with"convex6"for the “regular_polygon” pattern and instead throws an error. This most likely affects plots that mappattern_shapewhile also mappingpatternto a mix of “pch” and “regular_polygon” patterns (e.g. withscale_pattern_identity()) since the default shape scale supplies numericpchshapes; usescale_pattern_shape_manual()to supply valid shapes for each pattern instead. The default “regular_polygon” shape is still"convex6".An
NAvalue of an aesthetic is now always passed on to gridpattern where it may be meaningful e.g. anNApattern_fill2is now a transparent colour (previously replaced by the defaultpattern_fill2) and anNApattern_shapestill draws nothing for the “pch” pattern.
Deprecated features
-
create_polygon_df()andis_polygon_df()are (soft-)deprecated (#161) since nothing exported accepts apolygon_df(a data frame withx,y, andidcolumns). To fill the areas of a grob with patterns see the newwith_pattern_aes().
New features
New
make_GeomPattern()makes a pattern geom from (almost) any ggplot2 (or extension) geom: it draws the geom’s grob and fills each of its areas with the pattern of its row (useggplot2::make_constructor()to make itsgeom_*_pattern()function). Itsarea_byargument says how the areas are matched to the rows of the data ("row","group", or a function) or else (by default for a geom we don’t know) each area is traced back to its row by the fill it was drawn with ("trace"). Filling areas other than rectangles, polygons, and paths (e.g. circles or round rectangles) requires R (>= 4.2.0).We now re-export
gridpattern::with_pattern()whose newLayermethod makes a pattern layer from a layer e.g.with_pattern(geom_smooth(), pattern_fill = "white")(using our pattern geom for the layer’s geom if we have one elsemake_GeomPattern()). It also has a newggmethod which returns any other ggplot2 object as it is (e.g. a coord, scale, facet, theme,labs(), orguides()) so that it can be given a list of them and layers e.g. whatgeom_sf()returns:with_pattern(geom_sf(), pattern = "circle"). It is an error to give it a plot or a geom. ANULLin such a list is also left as it is e.g.with_pattern(list(geom_col(), if (flip) coord_flip())). Requires gridpattern (>= 1.6.0-17).New
make_geom_pattern()makes ageom_*_pattern()function (#168) from ageom_*()function e.g.geom_smooth_pattern <- make_geom_pattern(geom_smooth)(it keeps the function’s stat, position, and other defaults) or from a geom e.g.make_geom_pattern(ggridges::GeomDensityRidges, stat = ggridges::StatDensityRidges, position = ggridges::position_points_sina()).New
with_pattern_aes(),with_pattern_key(), anddefault_pattern_aes()for writing the draw methods of a pattern geom (#156) and a new “Developing Pattern Geoms” vignette.New
geom_contour_filled_pattern(),geom_density_2d_filled_pattern()(and its aliasgeom_density2d_filled_pattern()),geom_dotplot_pattern(), andgeom_hex_pattern()(and theirGeomContourFilledPattern,GeomDensity2dFilledPattern,GeomDotplotPattern, andGeomHexPatterngeoms) (#162).geom_dotplot_pattern()requires R (>= 4.2.0) (it is an error otherwise) andgeom_hex_pattern()requires hexbin.New
geom_point_pattern()which fills each point with a filled symbol (shape21 to 25, its default is 21) with its own pattern (e.g. a different image per point using the “image” pattern andpattern_filename) and itsdraw_key_point_pattern()legend key glyph. Points with other shapes are drawn as bygeom_point(). Requires R (>= 4.2.0) (it is an error otherwise).-
New
pattern_linewidthaesthetic for the stroke line width of patterns (matching ggplot2’s renaming of thesizeaesthetic tolinewidthfor line widths) with newscale_pattern_linewidth(),scale_pattern_linewidth_continuous(),scale_pattern_linewidth_discrete(),scale_pattern_linewidth_ordinal(),scale_pattern_linewidth_manual(), andscale_pattern_linewidth_identity()scales (#83). Usingpattern_sizefor line widths is now superseded (but not deprecated) and remains the fontsize of the “text” pattern:- If
pattern_linewidthis unset it falls back topattern_sizeso existing plots render unchanged. - If both are set
pattern_linewidthis the line width whilepattern_sizeis the fontsize (custom patterns may use both viaparams$pattern_linewidthandparams$pattern_size). - Unlike
scale_pattern_size()(which usesscales::area_pal()) the new continuous scale maps linearly to the range likeggplot2::scale_linewidth().
- If
Bug fixes and minor improvements
GeomTilePattern(and soGeomBin2dPattern) now has the samenon_missing_aesasggplot2::GeomTile.The
setup_data()ofGeomBarPattern,GeomColPattern, andGeomTilePatternnow uses their own (or their subclass’s) defaultwidthandheight(previously that ofggplot2::GeomBarorggplot2::GeomTile). They andGeomAreaPatternnow call thesetup_data()andsetup_params()of the ggplot2 geom they copy when the plot is drawn instead of a copy of them made when ggpattern was installed.GeomSfPatternnow has the same default aesthetics asggplot2::GeomSfe.g. its defaultlinetypeis now the theme’slinetype(previously that of a polygon i.e. the theme’sbordertype).Our geoms now draw the grob of the ggplot2 geom they extend and fill each of its areas with a pattern in place (using
gridpattern::with_pattern(), #158) instead of copying its grob-construction logic. Each area keeps the pattern of its row (e.g. each bar, polygon group, or contiguous piece of a ribbon gets its own gradient or image) and lines, points, and text (e.g. boxplot outliers, whiskers, and medians) are left alone. Each area’s fill, pattern, and border are now drawn in turn (like ggplot2 draws its areas) instead of every border being drawn above every pattern so overlapping areas stack correctly and the border shared by neighbouring areas (e.g. tiles) is partly covered by the later area. Requires gridpattern (>= 1.6.0-15).draw_key_polygon_pattern(),draw_key_boxplot_pattern(), anddraw_key_crossbar_pattern()now fill the area of ggplot2’sdraw_key_polygon(),draw_key_boxplot(), anddraw_key_crossbar()key glyphs with a pattern (usinggridpattern::with_pattern(), #158) instead of drawing their own glyphs. So legend key borders now have the same width as the geom’s borders (previously thinner), the border of boxplot and crossbar keys is drawn above the pattern, and boxplot and crossbar keys now respectorientationand the whisker, median, box, and staple graphical parameters.geom_ribbon_pattern(),geom_area_pattern(), andgeom_density_pattern()now support afilloralphathat varies along the ribbon (drawn as a gradient by ggplot2) in linear coordinates. Only the pattern aesthetics must be constant.The patterns of
geom_polygon_pattern()polygons with asubgroup(i.e. holes) and ofgeom_sf_pattern()are now positioned the same as those of other polygons (their bounding box was previously measured in the wrong viewport).geom_sf_pattern()still draws one pattern per row (filling all the polygons of aMULTIPOLYGONas one region) and now also fills each polygon of aGEOMETRYCOLLECTION(with the pattern of its row). Each row’s fill, pattern, and border are now drawn together (in row order like ggplot2) and its lines and points are no longer edited (so e.g. closed arrow heads are no longer hollowed out).-
Bumps required version of gridpattern to v1.6.0:
- This should fix a bug with patterns sometimes not showing up in the legend with larger
pattern_key_scale_factorvalues (#86). - We now recommend registering custom patterns with
gridpattern::register_pattern()instead of setting theggpattern_geometry_funcs/ggpattern_array_funcsglobal options (which still work but may clobber other registrations). The Developing Patterns vignette has been updated accordingly.
- This should fix a bug with patterns sometimes not showing up in the legend with larger
The default
pattern_resis now computed by gridpattern from the graphics device the plot is drawn on (instead of by us when the plot is built) so a plot built on one device but drawn on another now uses the resolution of the latter. In legend keys theggpattern_resoption is now scaled up just like the device resolution (an explicitly setpattern_resis still used as is).New Other {gridpattern} Patterns vignette (not included with CRAN version) (#79).
The documentation of the pattern aesthetics’ defaults has been updated (e.g. the default
pattern_alphaisNAi.e. keep the colours’ alpha rather than1).
ggpattern 1.3.1
CRAN release: 2026-03-07
Breaking changes
- Now requires ggplot2 (>= 4.0.2) and thus
R(>= 4.1). - All geom default aesthetics now use
from_theme()for colours, line widths, and line types. These changes were made to the ggplot2 analogues in ggplot2 4.0.0. - Turned off fallback for
sizetolinewidthtranslation ingeom_bar_pattern()/geom_col_pattern(). This fallback was turned off ingeom_bar()andgeom_col()in ggplot2 4.0.0.
Deprecated features
-
geom_boxplot_pattern(fatten)is deprecated. Usegeom_boxplot_pattern(median.linewidth)instead.fattenwas deprecated ingeom_boxplot()in ggplot2 4.0.0. - The
fattenargument ofgeom_crossbar_pattern()is deprecated. Usemiddle.linewidthinstead.fattenwas deprecated ingeom_crossbar()in ggplot2 4.0.0. - The
draw_quantilesparameter ofgeom_violin_pattern()is deprecated. Usequantile.linetypeinstead.draw_quantileswas deprecated ingeom_violin()in ggplot2 4.0.0.
New features
- We now export
GeomBin2dPattern. -
geom_boxplot_pattern()gainswhisker.colour,whisker.color,whisker.linetype,whisker.linewidth,staple.colour,staple.color,staple.linetype,staple.linewidth,median.colour,median.color,median.linetype,median.linewidth,box.colour,box.color,box.linetype, andbox.linewidthparameters for per-component styling. This matches the changes ingeom_boxplot()in ggplot2 4.0.0. -
geom_crossbar_pattern()gainsmiddle.colour,middle.color,middle.linetype,middle.linewidth,box.colour,box.color,box.linetype, andbox.linewidthparameters for per-component styling. This matches the changes ingeom_crossbar()in ggplot2 4.0.0. -
geom_violin_pattern()gainsquantile.colour,quantile.color,quantile.linetype, andquantile.linewidthparameters for styling quantile lines. This matches the changes ingeom_violin()in ggplot2 4.0.0.
Bug fixes and minor improvements
- We now construct several geom functions from the ggpattern
Geomobjects withmake_constructor()and these ggpatternGeomobjects now directly inherit more methods from the ggplot2Geomobjects they extend. -
widthis now an aesthetic (default0.9) ingeom_bar_pattern()andgeom_col_pattern()rather than a function parameter andGeomBoxplotPatternandGeomViolinPatterndefault aesthetics now includewidth = 0.9. These match upstream changes in ggplot2 4.0.0.
ggpattern 1.2.1
CRAN release: 2025-08-27
New features
- Adds
guideargument toscale_pattern_angle_discrete(),scale_pattern_density_discrete(),scale_pattern_spacing_discrete(),scale_pattern_xoffset_discrete(),scale_pattern_yoffset_discrete(),scale_pattern_aspect_ratio_discrete(),scale_pattern_key_scale_factor_discrete(),scale_pattern_scale_discrete(),scale_pattern_phase_discrete(),scale_pattern_frequency_discrete(),scale_pattern_res_discrete(),scale_pattern_rot_discrete()(#139).
ggpattern 1.1.4
CRAN release: 2025-01-28
Bug fixes and minor improvements
- Updated a couple of examples to use the
linewidthaesthetic instead of thesizeaesthetic which was deprecated in ggplot2 3.4.0.
ggpattern 1.1.3
CRAN release: 2024-12-13
Bug fixes and minor improvements
- Added alt text to vignette and README images.
- Added missing package anchors to a few Rd cross-references (#128).
ggpattern 1.1.1
CRAN release: 2024-06-04
Breaking changes
- The argument
binwidthhas been removed fromgeom_bar_pattern(). This argument was deprecated with ggpattern 0.1.0 (2020-04-01). - The
draw_key_polygon_pattern()called bygeom_sf_pattern()is now passed in its actual aspect ratio (instead of 1). This may cause your legends togeom_sf_pattern()to look different.
Deprecated features
- In line with upstream changes in ggplot2 the
transargument has been deprecated in various scales functions. Use the newtransformargument instead (#113). -
outline.type = "legacy"is now formally deprecated ingeom_area_pattern()andgeom_ribbon_pattern(). Useoutline.type = "full"instead.outline.type = "legacy"was deprecated with ggpattern 0.1.0 (2020-04-01) but this is the first timeoutline.type = "full"has been supported as an alternative.
New features
Geoms now more consistently expose the
lineendandlinejoinparameters (#94). This matches a similar upstream change in ggplot2 3.4.0.geom_area_pattern()andgeom_ribbon_pattern()now acceptoutline.type = "lower"andoutline.type = "full".geom_density_pattern()now exposes theoutline.typeparameter.geom_bar_pattern()andgeom_col_pattern()now accept parameterjust. Thejustparameter was added toggplot2::geom_bar()andggplot2::geom_col()with ggplot2 3.4.0.geom_boxplot_pattern()now accept theoutliersandstaplewidthparameters. Theoutliersandstaplewidthparameters were added togeom_boxplot()in ggplot2 3.5.0.geom_sf_pattern()now accepts thearrowparameter. Thearrowparameter was added togeom_sf()in ggplot2 3.5.0.geom_violin_pattern()now accepts theboundsparameter. Theboundsparameter was added togeom_violin()in ggplot2 3.5.0.Each pattern aesthetic may now be a list of vectors with each list element providing that aesthetic for a different pattern (#100). Most builtin gridpattern “geometry” patterns support multiple fill colors etc. which previously we could only access in ggpattern via custom patterns.
The
fill,pattern_fill, andpattern_fill2aesthetics may now be (a list of) gradient/pattern fills (in addition to color strings) (#112). Note using gradient/pattern fills will require R (>= 4.2), a graphics device with support for the gradient/pattern fill feature, and will work only for a subset of patterns (i.e. most of the “geometry” patterns). Use of just color fills should continue to work on a wider variety of R versions, graphics devices, and patterns.{ggpattern} now supports the
pattern_unitsaesthetic (#81). Supported by most “geometry” patterns. It sets thegrid::unit()used by thepattern_spacing,pattern_xoffset,pattern_yoffset, and (for the “wave” pattern) thepattern_frequencyaesthetics. Default is “snpc” while “cm” and “inches” are likely alternatives.geom_bin_2d_pattern()is now an alias forgeom_bin2d_pattern(). This matches ggplot2 which has bothgeom_bin_2d()andgeom_bin2d().
Bug fixes and minor improvements
-
draw_key_boxplot_pattern(),draw_key_crossbar_pattern(), anddraw_key_polygon_pattern()aspect_ratioargument now defaults toget_aspect_ratio(). - Several (continuous) scales now have an
...argument which will be passed toggplot2::continuous_scale(). - The default
na.valueforscale_pattern_continuous(),scale_pattern_discrete(), andscale_pattern_manual()is now “none” (#107).
ggpattern 1.0.1
CRAN release: 2022-11-09
Deprecated features
- In line with upstream changes in ggplot2 a
linewidthaesthetic has been introduced and supersedes thesizeaesthetic for scaling the width of patterned area border lines (#82).sizewill remain functioning but deprecated for these geoms and it is recommended to update all code to reflect the new aesthetic.
Continue to use thesizeaesthetic to adjust the size of any points ingeom_sf_pattern().
ggpattern 1.0.0
CRAN release: 2022-08-30
Bug fixes and minor improvements
- Fixes bug in “image” pattern when
pattern_type = "tile"(#37). Transparent parts of tiled images are now consistently transparent. We now support thepattern_gravityaesthetic whenpattern_type = "tile".
ggpattern 0.4.2
CRAN release: 2022-02-23
Breaking changes
To turn off “clipping” certain built-in patterns with the new R 4.1 graphic features and instead use a raster image approximation one should now use
options(ggpattern_use_R4.1_masks = FALSE)instead ofoptions(ggpattern_use_R4.1_clipping = FALSE). Alternatively, usingoptions(ggpattern_use_R4.1_features = FALSE)to turn off all R 4.1 features will continue to work.-
{ggpattern} removes the following data/functions which were deprecated in a previous version of {ggpattern}:
convert_polygon_df_to_polygon_grob()convert_polygon_df_to_polygon_sf()convert_polygon_sf_to_polygon_df()
Defunct functions are no longer exported.
New features
- {ggpattern} now supports
geom_histogram_pattern()(#71)
Bug fixes and minor improvements
-
geom_sf_pattern()andgeom_polygon_pattern()now support polygons with holes by using “alpha masking” instead of a “clipping path”. If R 4.1 alpha mask feature is not supported by the active graphics device (or the masking feature is declined) we use a raster image approximation of the pattern. Resolution of the raster approximation can be adjusted by thepattern_resaesthetic whose default in turn can be adjusted by the"ggpattern_res"global option.This change fixes patterns filling holed polygons in certain graphic devices (#68). This change fixes patterns sometimes escaping plot window (#60).
draw_key_polygon_pattern(),GeomMapPattern,GeomPolygonPattern, andGeomSfPatternnow draws a “border” grob on top of the “pattern” grob (#72).Continuous “pattern_colour”, “pattern_fill”, and “pattern_fill2” color scales’ default “colourbar” guide support should now work.
scale_pattern_size_continuous()now uses “pattern_size” aesthetic instead of “size” aesthetic in underlyingggplot2::continuous_scale()call.We now export
scale_pattern_alpha()which is an alias ofscale_pattern_alpha_continuous().
ggpattern 0.3.1
Breaking changes
{ggpattern} removes the following data/functions which were deprecated in a previous version of {ggpattern}:
calculate_bbox_polygon_df()convert_img_to_array()convert_polygon_df_to_alpha_channel()create_gradient_img()fetch_placeholder_img()fill_area_with_img()-
magick_filter_names, instead usemagick::filter_types() -
magick_gravity_names, instead usemagick::gravity_types() -
magick_pattern_intensity_names, instead usegridpattern::names_magick_intensity -
magick_pattern_names, instead usegridpattern::names_magick -
magick_pattern_stripe_names, instead usegridpattern::names_magick_stripe -
placeholder_names, instead usegridpattern::names_placeholder rotate_polygon_df()
Deprecated features
{ggpattern} now deprecates the following data/functions, they may be removed in a future version of {ggpattern}:
convert_polygon_df_to_polygon_grob()convert_polygon_df_to_polygon_sf()convert_polygon_sf_to_polygon_df()
New features
-
{ggpattern} now supports the following aesthetics (#45):
-
pattern_grid: Supported by most “geometry” patterns. Default is “square” while “hex” and “hex_circle” allow hexagonal layouts. -
pattern_res: Supported by “array” patterns. Allow user to explicitly set resolution of image-based patterns. -
pattern_rot: Used by “pch”, “regular_polygon”, “rose”, and “text” patterns to rotate symbol within pattern. ‘rot’ is parameter used ingrid:textGrob()to indicate rotation andpattern_anglealready used to rotate entire pattern.
-
Bug fixes and minor improvements
-
geom_polygon_pattern()andgeom_sf_pattern()now support polygons with holes (#26, #44). If R 4.1 clipping features are not supported by the graphic device (or the clipping feature is declined) we must use a raster image approximation of the pattern. Resolution of the raster approximation can be adjusted by thepattern_resaesthetic whose default in turn can be adjusted by the"ggpattern_res"global option.
ggpattern 0.2.0
Breaking changes
{ggpattern} now uses {gridpattern} to generate pattern grobs. This means there are minor tweaks to visual behavior:
- ‘pattern_spacing’, ‘pattern_xoffset’, and ‘pattern_yoffset’ are now interpreted as ‘spnc’ units instead of ‘npc’ units. and the center of the pattern “grid” is now the center of the viewport. To exactly restore the original appearance of {ggpattern} “geometry” patterns one may need to tweak the ‘pattern_density’, ‘pattern_spacing’, ‘pattern_xoffset’, and/or ‘pattern_yoffset’ aesthetics.
- The resolution of “array” patterns should be close but not identical to before.
In particular placeholder images will likely be different. - Custom {ggpattern} patterns can no longer use the same name as a {ggpattern} / {gridpattern} builtin pattern and an error will be thrown if you try to do so.
The following functions copied from {ggplot2} are no longer exported by {ggpattern}:
-
alpha(), instead useggplot2::alpha()orscales::alpha() -
flip_data(), instead useggplot2::flip_data() -
flipped_names(), instead useggplot2::flipped_names() -
gg_dep(), instead useggplot2::gg_dep() -
has_flipped_aes(), instead useggplot2::has_flipped_aes() -
remove_missing(), instead useggplot2::remove_missing() -
should_stop(), instead useggplot2::should_stop() -
waiver(), instead useggplot2::waiver()
Deprecated features
{ggpattern} now deprecates the following data/functions, they may be removed in a future version of {ggpattern}:
calculate_bbox_polygon_df()convert_img_to_array()convert_polygon_df_to_alpha_channel()create_gradient_img()fetch_placeholder_img()fill_area_with_img()-
magick_filter_names, instead usemagick::filter_types() -
magick_gravity_names, instead usemagick::gravity_types() -
magick_pattern_intensity_names, instead usegridpattern::names_magick_intensity -
magick_pattern_names, instead usegridpattern::names_magick -
magick_pattern_stripe_names, instead usegridpattern::names_magick_stripe -
placeholder_names, instead usegridpattern::names_placeholder rotate_polygon_df()
New features
-
{ggpattern} now supports all patterns provided by {gridpattern}. In particular {gridpattern} provides the following “new” patterns:
- “ambient” (the suggested package ambient must be installed)
- “pch”
- “polygon_tiling”
- “regular_polygon”
- “rose”
- “text”
- “wave”
- “weave”
‘pattern_fill2’ can now be used to set the fill for the vertical lines in the ‘crosshatch’ pattern.
By default, if unset, it uses ‘pattern_fill’ (#35).‘circle’ pattern can now be adjusted by ‘pattern_type’ and ‘pattern_subtype’. See
help("grid.pattern_circle", package = "gridpattern")for more info.‘gradient’ pattern can now use grid gradient feature introduced in R v4.1.0 if
options(ggpattern_use_R4.1_gradients = TRUE).-
The following package options can now be set by
options():-
ggpattern_use_R4.1_clippingIfTRUEuse the grid clipping path feature introduced in R v4.1.0 else do arasterGrobapproximation of the clipped pattern. -
ggpattern_use_R4.1_featuresIfTRUEsets the default for all the otherggpattern_use_R4.1_*options arguments toTRUE. -
ggpattern_use_R4.1_gradientsIfTRUEuse the grid gradient feature introduced in R v4.1.0 else do arasterGrobapproximation of the gradient pattern. -
ggpattern_use_R4.1_masksIfTRUEuse the grid mask feature introduced in R v4.1.0. Available for use in custom patterns. -
ggpattern_use_R4.1_patternsIfTRUEuse the grid pattern feature introduced in R v4.1.0. Available for use in custom patterns.
-
ggpattern 0.1.3 2020-06-28
- Support POLYGON in
geom_sf_pattern()(Issue #5)
ggpattern 0.1.2 2020-06-28
- Fix issue with attempts to fill an area with a pattern when it has zero area. (Issue #9)
ggpattern 0.1.1 2020-04-23
- Use
magick::image_data()instead ofmagick::as_EBImage()for internal conversion of images to arrays inconvert_img_to_array()
