trevorld / ggpattern

ggplot geoms with pattern fills
https://trevorldavis.com/R/ggpattern/dev/
Other
359 stars 18 forks source link

using without importing the library #50

Closed idavydov closed 3 years ago

idavydov commented 3 years ago

Is there a way to use this library without calling library(ggpattern)?

I get the following error:

df <- data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1))

ggplot2::ggplot(df) +
  ggplot2::aes(level, outcome, pattern_fill = level) +
  ggpattern::geom_col_pattern() 
#> Loading required namespace: memoise
#> Error in grDevices::col2rgb(colour, alpha = TRUE): invalid color name 'a'

Created on 2021-07-26 by the reprex package (v2.0.0)

Works fine if I add library(ggpattern) at the very top.

P.S. Great library by the way, thank you.

trevorld commented 3 years ago

This is a duplicate of #40 . Explicitly set your pattern_fill values or explicitly add in a ggpattern::scale_pattern_fill_discrete() (which {ggplot2} can't find if it isn't visible to it).

idavydov commented 3 years ago

Great, thank you very much.