devoutsvg icon indicating copy to clipboard operation
devoutsvg copied to clipboard

Default Specifications (Bugs)

Open bransonf opened this issue 5 years ago • 1 comments

Hey @coolbutuseless

Found two bugs for you:

First here's the code to reproduce:

library(ggplot2)
library(svgpatternsimple)
library(devout)
library(sf)

# load test data
stl <- st_read('https://bransonf.com/data/stl.geojson')
stl[grep('Park', stl$neighborhood), 'fill'] <- 1
stl[grep('Park', stl$neighborhood, invert = TRUE), 'fill'] <- 0


# define patterns
pattern0 <- svgpatternsimple::encode_pattern_params_as_hex_colour(
  pattern_name = 'null'  
)

pattern1 <- svgpatternsimple::encode_pattern_params_as_hex_colour(
  pattern_name = 'hex',
  spacing = .5,
  colour = '#2606B8',
  fill = '#C21919'
)

# open an SVG graphics device
svgout(filename = "gmap.svg", pattern_pkg = 'svgpatternsimple')

# make a ggplot
ggplot() +
  geom_sf(aes(fill = as.factor(fill)),
          data = stl) +
  scale_fill_manual(
    values = c(
      '0' = pattern0,
      '1' = pattern1
    )
  )
# close graphics device
invisible(dev.off())

And the output: issue

The hexagon pattern should be blue, but it is instead inheriting the default defined in this line

As far as the reason the pink squares are defaulting for the ggplot background, I haven't traced this.

bransonf avatar Oct 12 '19 00:10 bransonf

Thanks for the bug report. I hope to get back to this soon.

coolbutuseless avatar Dec 05 '19 02:12 coolbutuseless