R语言 ggplot2 图表中如何缩小 pattern 中线的粗细

在 R语言 ggplot2 中,geom_bar_pattern() 函数可以用来创建带图案的条形图。有时候,我们可能需要缩小 pattern 中线的粗细,以提高图表的清晰度。

可以通过增加 geom_bar_pattern() 函数中的 line_width 参数来缩小 pattern 中线的粗细。例如,将 linewidth 的值从 .1 降低到 .05

ggplot(data,aes(G, value, fill = G))+
    coord_cartesian(expand = F, xlim = c(.2, 6.55), ylim = c(0, 180))+
    scale_y_continuous(breaks = seq(0, 180, 20))+
    stat_summary(geom = "errorbar",fun.data = 'mean_sd', width = 0.45)+
    stat_summary(aes(pattern = G, pattern_angle  = G, pattern_spacing = G),
                 fun = "mean", position = "dodge", size = 0.3,
                 geom = "bar_pattern", colour = 'black', width = 0.75, fill = 'white', linewidth = .1, line_width = 0.05)+
    scale_pattern_spacing_manual(values = c(0, 0.03, 0.03, 0.06,0.03, 0.10))+
    scale_pattern_angle_manual(values = c(0, 30, 180, 150,90, 0))

这将缩小 pattern 中线的粗细。您可以根据需要调整 line_width 的值。

注意:

  • line_width 参数的值越小,pattern 中线的粗细就越小。
  • 调整 line_width 的值时,可能需要调整其他参数,例如 linewidth,以获得最佳效果。
R语言 ggplot2 图表中如何缩小 pattern 中线的粗细

原文地址: https://www.cveoy.top/t/topic/nc6a 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录