Closed zhanghaoipp closed 3 years ago
I use the command bleow to make the bar plot, but you can see the patten spacing in the legend and main plot is different, the legend is smaller. How to resolve this problem? Thank you!
ggplot(tg, aes(x=Sample.x, y=content)) + geom_col_pattern(aes(pattern=toxin), pattern_spacing=0.01, pattern_fill='black', pattern_color='black', fill='white', color='black') + geom_errorbar(aes(ymin = error_min, ymax=error_max), width=0.4) + theme(panel.background = element_blank(), axis.line = element_line(colour = 'black'), legend.title = element_blank()) + xlab('') + ylab('mg/kg') + geom_text(x='287', y=0.09, label='') + geom_text(x='272', y=0.17, label='') + geom_hline(yintercept = mean(grain$sum), linetype = 'dashed', color='grey50')
The aesthetic pattern_key_scale_factor can be used to adjust the legend pattern spacing.
pattern_key_scale_factor
I use the command bleow to make the bar plot, but you can see the patten spacing in the legend and main plot is different, the legend is smaller. How to resolve this problem? Thank you!
ggplot(tg, aes(x=Sample.x, y=content)) + geom_col_pattern(aes(pattern=toxin), pattern_spacing=0.01, pattern_fill='black', pattern_color='black', fill='white', color='black') + geom_errorbar(aes(ymin = error_min, ymax=error_max), width=0.4) + theme(panel.background = element_blank(), axis.line = element_line(colour = 'black'), legend.title = element_blank()) + xlab('') + ylab('mg/kg') + geom_text(x='287', y=0.09, label='') + geom_text(x='272', y=0.17, label='') + geom_hline(yintercept = mean(grain$sum), linetype = 'dashed', color='grey50')![Figure6-3](https://user-images.githubusercontent.com/15721672/110190968-11c54300-7e61-11eb-9373-f766606fc95e.jpg)