draw_key_polygon_size: A polygon key glyphs for legends of size aesthetics

Description Usage Arguments Value Examples

View source: R/polygon.R

Description

A polygon key glyphs for legends of size aesthetics

Usage

1

Arguments

width

A numeric to control the width of keys, which should be between 0 and 1. The default value is 0.8.

height

A numeric to control the height of keys, which should be between 0 and 1. The default value is 0.8.

Value

A Key glyphs function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
library(dplyr)
library(sf)
library(ggplot2)


nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"),
                 quiet = TRUE)

nc2 <- nc %>% arrange(desc(AREA)) %>% slice(1:2)


ggplot(nc2) +
    geom_sf(aes(size = AREA),
            colour = "red") +
    scale_size(breaks = c(0.24, 0.241)) +
    theme(legend.key.size = unit(0.15, "npc"))


ggplot(nc2) +
    geom_sf(aes(size = AREA),
            colour = "red",
           key_glyph = draw_key_polygon_size()) +
    scale_size(breaks = c(0.24, 0.241)) +
    theme(legend.key.size = unit(0.15, "npc"))


ggplot(nc2) +
    geom_sf(aes(size = AREA),
            colour = "red",
            key_glyph = draw_key_polygon_size(0.9, 0.3)) +
    scale_size(breaks = c(0.24, 0.241)) +
    theme(legend.key.size = unit(0.15, "npc"))

microly/ggkey documentation built on Nov. 4, 2019, 6:52 p.m.