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

R中ggplot2的geom_smooth平滑曲线:阴影区域含义咨询

Understanding the Shaded Area in ggplot2's geom_smooth() for Academic Writing

Great question—this shaded area is a key statistical component in your plot, and it’s absolutely relevant for academic writing. Let’s break it down clearly:

What the Shaded Area Actually Is

The gray shadow around your loess curve is a 95% confidence interval (CI). Since ggplot2 auto-selected method = 'loess' (local weighted regression), this interval is calculated based on the uncertainty of the local regression fits at each year.

In plain terms:

  • For every year on your x-axis, the shaded range represents the interval where we can be 95% confident the true average number of sentiment words (across all states in your dataset) falls.
  • Wider shadow = higher uncertainty in the fit for that year (maybe fewer data points, or more variability in sentiment counts across states).
  • Narrower shadow = more confidence in the fitted trend for that year (more consistent data across states).

Why It’s Useful for Academic Writing

Confidence intervals are standard in academic visualizations because they:

  • Avoid presenting trends as absolute facts—instead, they show the statistical reliability of your fitted pattern.
  • Help readers interpret how much trust to place in the observed trend (e.g., a wide interval might mean a year has sparse or variable data that needs further investigation).

How to Adjust It (If Needed)

You can tweak this behavior with parameters in geom_smooth():

  • Change the confidence level: Use level = 0.99 to get a 99% CI, or level = 0.90 for a 90% CI, e.g.:
    ggplot(sentiment, aes(x = year, y = nrc_sent$sentiment)) + 
      geom_smooth(method = "loess", level = 0.99) +
      scale_x_continuous(breaks = round(seq(min(sentiment$year), max(sentiment$year), by = 2),1))+
      labs(x="", y="")
    
  • Hide the shadow entirely: Use se = FALSE, but this is generally not recommended in academic work unless you have a specific reason (e.g., focusing solely on the trend line for simplicity, and you explicitly explain the omission in your text).

Example Caption for Academic Papers

To properly contextualize the plot in your writing, you could add a caption like this:

Figure X: Trend in sentiment word count by year. The line shows a local weighted regression (loess) fit, and the shaded area represents the 95% confidence interval, indicating the statistical uncertainty of the fitted trend.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 10:13:35