You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在ggplot2中使用黑白配色方案区分Dogri语单辅音与长辅音(Singleton/Geminate)?

Black-and-White ggplot2 Boxplots for Singleton vs Geminate Consonants

Since most scientific journals discourage color figures, here are practical, flexible solutions to adapt your ggplot2 code for black-and-white visualization of your Dogri consonant duration data—way more customizable than base R's boxplot()!

Option 1: Grayscale Fill with Distinct Mean Points

This uses a grayscale gradient for fill, paired with different point shapes for the mean values, ensuring clear differentiation in black-and-white prints:

ggplot(df, aes(x = Place, y = C2, fill = Consonant)) +
  # Boxplot with solid black borders for crispness
  geom_boxplot(color = "black", position = position_dodge(width = 0.75)) +
  # Add mean points, mapped to shape for extra distinction
  stat_summary(fun = "mean",
               geom = "point",
               aes(shape = Consonant),
               position = position_dodge(width = 0.75),
               size = 2) +
  # Grayscale fill: lighter for Singleton, darker for Geminate
  scale_fill_grey(start = 0.8, end = 0.3,
                  labels = c("Geminate", "Singleton")) +
  # Assign unique shapes to each consonant type
  scale_shape_manual(values = c(16, 17)) +
  # Update labels for clarity
  labs(title = "Duration of word-medial (C2) consonant for Dogri singleton and geminates",
       x = "Place of articulation for C2",
       y = "C2 duration (ms)",
       fill = "Consonant type",
       shape = "Consonant type") +
  # Use a clean, journal-friendly black-and-white theme
  theme_bw()

Key Details:

  • scale_fill_grey() lets you control the lightness/darkness of each group (adjust start/end to tweak contrast)
  • Mapping shape to Consonant in stat_summary ensures mean points are distinguishable even if fill grays are close
  • theme_bw() removes the default gray background, making the plot look more polished for publication

Option 2: Fill + Line Type + Shape (Dual Differentiation)

If you want to avoid relying solely on grayscale, combine subtle fill differences with distinct line types and point shapes—this is great for ensuring clarity in low-quality prints:

ggplot(df, aes(x = Place, y = C2, fill = Consonant, linetype = Consonant)) +
  geom_boxplot(color = "black", position = position_dodge(width = 0.75)) +
  stat_summary(fun = "mean",
               geom = "point",
               aes(shape = Consonant),
               position = position_dodge(width = 0.75),
               size = 2) +
  # Soft fill contrast: white vs light gray
  scale_fill_manual(values = c("grey90", "white")) +
  # Different line styles for boxplot borders
  scale_linetype_manual(values = c("solid", "dashed")) +
  # Unique shapes for mean points
  scale_shape_manual(values = c(16, 17)) +
  labs(title = "Duration of word-medial (C2) consonant for Dogri singleton and geminates",
       x = "Place of articulation for C2",
       y = "C2 duration (ms)",
       fill = "Consonant type",
       linetype = "Consonant type",
       shape = "Consonant type") +
  # Minimalist classic theme (no grid lines, clean axes)
  theme_classic()

Key Details:

  • The combination of fill, linetype, and shape gives multiple visual cues to distinguish Singleton vs Geminate
  • theme_classic() is ideal for academic journals, as it eliminates distracting grid lines

Both options retain all the flexibility of ggplot2 (like adjusting dodge width, customizing labels, or adding other stats) while adhering to black-and-white figure requirements.

内容的提问来源于stack exchange,提问作者Pranav_b

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 18:32:34