Closed cogerk closed 4 years ago
Resolved, the difference in scale between the two figures resulted in very skinny bars that could not support a pattern image. Once I made my viewport a bit bigger and my columns a bit wider, it looked great.
One idea I had to "idiot-proof" this would be to add some language to the error/warning saying "Is your graph too small?" or something like that. It could also be made even more apparent to the user by instead using the classic ggplot version of the function without a pattern so that the user can see what the dimensions of the plot they just tried to make are, see that they've created an area way too small to support a pattern image, and realize the issue quickly.
Hey! I absolutely love this package so far, but I'm running into an issue. I'm not sure if it is a bug or operator error.
For some reason my specific dataframe keeps throwing an error. Below I've reproduced the issue, first with a working example (modified from a vignette) and then with my dataframe. Any help is greatly appreciated, thanks!
works great!
df <- data.frame( group = c("Cool", "But", "Cool", "But"), value = c(10, 20, 30, 40), x=c(1,1,5,5) )
ggplot(df, aes(x=x, y = value, pattern_type = group, pattern_fill = group)) + geom_bar_pattern(position=position_dodge2(), color='black', size=0.25, pattern = 'magick', width = 1, stat = "identity", fill = 'white', pattern_scale = .25, pattern_aspect_ratio = 1, pattern_key_scale_factor = 1.5 ) + scale_pattern_fill_manual(values=c('white','grey40', 'black')) + scale_pattern_type_manual(values = ggpattern::magick_pattern_names[1:4])
doesn't work :(
df2 <- tibble(Day=c(0,0,0, 31,31,31, 118,118,118), mean=c(1,1.5,2, 2,2.5,2, 5,3, 2), group=c('AOB','AOA','NOB', 'AOB','AOA','NOB', 'AOB','AOA','NOB'))
ggplot(df2, aes(x=Day, y = mean, pattern_type = group, pattern_fill = group)) + geom_bar_pattern(position=position_dodge2(), color='black', size=0.25, pattern = 'magick', width = 1, stat = "identity", fill = 'white', pattern_scale = .25, pattern_aspect_ratio = 1, pattern_key_scale_factor = 1.5 ) + scale_pattern_fill_manual(values=c('white','grey40', 'black')) + scale_pattern_type_manual(values = ggpattern::magick_pattern_names[1:4])
Resulting error:
Error in png(png_file, width = width, height = height) : invalid quartz() device size In addition: Warning messages: 1: create_magick_pattern_img(): zero size 2: In FALSE : create_pattern_array(): Expecting a numeric RGBA array with dim = c(88, 0, 4) but instead got a "array" of type double with dimensions c(88L, 10L, 4L)