Closed kklot closed 3 years ago
Hi @kklot
You will have to manually set sizes with scale_pattern_size*
functions.
library(ggplot2)
library(ggpattern)
#>
#> Attaching package: 'ggpattern'
#> The following objects are masked from 'package:ggplot2':
#>
#> flip_data, flipped_names, gg_dep, has_flipped_aes, remove_missing,
#> should_stop, waiver
df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
ggplot(df, aes(trt, outcome)) +
geom_col_pattern(aes(fill=trt, pattern_spacing = trt, pattern_density = trt),colour='black', pattern = 'circle') +
theme_bw() +
labs(title = "ggpattern + coord_fixed()") +
coord_fixed(ratio = 1/2) +
scale_pattern_spacing_manual(values = c(a = 0.05, b = 0.1, c = 0.2)) +
scale_pattern_density_manual(values = c(a = 0.1, b = 0.05, c = 0.025))
Created on 2020-12-19 by the reprex package (v0.3.0)
I mapped a variable to spacing, so using
pattern_spacing
withinaes
works. But it also changes the size of the circle (I'm usingpattern="circle"
) which conveys different meanings as it is another dimension. I kept a fixedpattern_density=0.05
.How can I change the spacing without changing the size of the pattern?