小编Ed2*_*122的帖子

ggplot aes fill 没有明显原因无法工作

我已经制作了 ggplot 图形数百次(如果不是数千次),并且大约 99% 的时间使用 aes 将填充设置为基于 df 中的变量。由于某种原因,填充颜色不起作用(点每次都是黑色的),我不明白为什么,代码中没有任何明确的内容。我已经尝试了几乎所有我能想到的对代码的调整或调整,一次删除一个行或一个部分来测试哪个部分出错了。即使我只运行前两行,除了黑色之外我没有得到任何填充颜色。有什么想法吗?

ggplot(mean_score_by_type, aes(x = Inference, y = Direct, fill=as.factor(Age_Group))) +
  geom_point(alpha=0.7, size=4, stroke=1, position=position_jitter(width=0.05, height=0.05)) +
  scale_fill_discrete(name = "Age (Years)") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_y_continuous(breaks=seq(0,1,0.25), limits=c(0.25,1.05)) +
  labs(y="Direct", x="Inference", title="Proportion of Correct Responses") +
  geom_vline(xintercept=.56, color="red", linetype=2) + 
  geom_hline(yintercept=.56, color="blue", linetype=2) +
  facet_wrap(~Group)
Run Code Online (Sandbox Code Playgroud)

几行数据:

 Participant Age_Group Control-ID Control-MC Direct Inference   Group
        1         6      1.000      1.000     1.00      0.75 Under 7
        2         6      1.000      1.000     1.00      0.00 Under 7
        3         4 …
Run Code Online (Sandbox Code Playgroud)

r fill ggplot2 aesthetics

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

aesthetics ×1

fill ×1

ggplot2 ×1

r ×1