繁体   English   中英

条形 Plot 3 个自变量合一 plot

[英]Bar Plot with 3 independent variables in one plot

我的 df 看起来像这样:

Training_Task <- c("Imag", "Imag", "Imag", "Imag", "Rephrasing", "Rephrasing", "Rephrasing", "Rephrasing")
emotionality <- c("emo", "neu", "emo", "neu", "emo", "neu", "emo", "neu")
target_type <- c("novel", "novel", "pseudo", "pseudo", "novel", "novel", "pseudo", "pseudo")
acc <- c(93, 95, 97, 98, 96, 94, 92, 90)
df <- data.frame(Training_Task, emotionality, target_type, acc)

现在我想创建一个看起来像这样的条形 plot:

plot = ggplot(df, aes(fill =Training_Task, y=acc, x=target_type))

但我希望通过饱和的情感条(情感 = emo)和苍白的中性条(情感 = neu)来添加 IV 情感。

有没有办法做到这一点?

您可以在审美中使用alpha并将 position 设置为dodge

ggplot(df) +
  geom_bar(aes(fill = Training_Task, y=acc, x=target_type, alpha = emotionality), stat = 'identity', position = "dodge") +
  theme_minimal() +
  scale_alpha_discrete(range = c(1,0.4))

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM