scale_fill_geopattern | R Documentation |
Fill scale using the FGDC Digital Cartographic Standard for Geologic Map Symbolization. Fill values should correspond to specific pattern codes (see "Details").
scale_fill_geopattern(na.value = "grey50", ...)
For specific codes, see the "pattern numbers" in the full pattern chart
for valid code
values. Daven Quinn has also assembled more accessible
documentation of the map patterns/codes
and lithology patterns/codes.
rmacrostrat::def_lithologies()
can also be used to look up pattern codes
for various lithologies (see the "fill" column). Note that codes associated
with color variants (e.g., "101-M") are supported but will result in the
default color variant instead (usually black and white, e.g., "101-K").
These patterns were originally processed and optimized by Daven Quinn and are hosted on GitHub.
Pattern fills are not supported on all graphics devices.
Not all devices are under active development, and such devices are unlikely
to add support for new features (such as pattern fills). The new features
have only been implemented on a subset of graphics devices so far:
cairo_pdf()
, cairo_ps()
, x11(type="cairo")
,
png(type="cairo")
,
jpeg(type="cairo")
,
tiff(type="cairo")
, svg()
, and pdf()
. Although
there is no support yet for quartz()
or windows()
, almost all of the
graphics devices above will work on all major platforms. Further, the
ragg and
svglite packages contain graphics
devices that support patterns. When using a graphics device where patterns
are not supported, closed shapes will be rendered with a transparent fill.
Note that, at least on Windows machines, the default device in RStudio and
in the knitr package is png()
, which does not support patterns. In
RStudio, you can go to ‘Tools > Global Options > General > Graphics’ and
choose the ‘Cairo PNG’ device from the dropdown menu to display patterns.
Similar issues may arise when using RStudio on other operating systems.
FGDC patterns:
geo_pattern()
,
grid.pattern_geo()
library(ggplot2)
vals <- c("101", "313", "603", "733")
ggplot(mpg, aes(factor(cyl), fill = vals[factor(cyl)])) +
geom_bar() +
scale_fill_geopattern(name = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.