簡體   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