Closed
Description
The guide-bins seems cannot work with geom_sf.
Some examples:
For geom_point, both "coloursteps" and "bins" guides work well:
library(ggplot2)
library(tibble)
ggplot(tibble(x = 1:10, y = x, z = x), aes(x, y, fill = z)) +
geom_point(shape = 21, size = 10) +
scale_fill_stepsn(guide = "coloursteps", colours = terrain.colors(10))
ggplot(tibble(x = 1:10, y = x, z = x), aes(x, y, fill = z)) +
geom_point(shape = 21, size = 10) +
scale_fill_stepsn(guide = "bins", colours = terrain.colors(10))
But, for geom_sf, only "coloursteps" can work.
There seems to be a bug in guide-bins.
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"))
ggplot() +
geom_sf(aes(fill = AREA), data = nc) +
scale_fill_stepsn(guide = "coloursteps", colours = terrain.colors(10))
ggplot() +
geom_sf(aes(fill = AREA), data = nc) +
scale_fill_stepsn(guide = "bins", colours = terrain.colors(10))
# Error in do.call("cbind", lapply(guide$geoms, function(g) g$data$size/10))[seq_len(n_keys), :
# subscript out of bounds
Metadata
Metadata
Assignees
Labels
No labels