【问题标题】:Highlight bars >= 5 in one column only, geom_col(), R仅在一列中突出显示条 >= 5,geom_col(),R
【发布时间】:2021-05-04 17:49:19
【问题描述】:

我使用 ggplot geom_col 创建了以下列图并突出显示 >= 5 的列。目标是仅突出显示结构列中 >= 5 的值,而其他列不突出显示。

数据框 FC_TS 有三列:Last NameFeatureValue,出于数据保护的原因,我无法发布。 Feature 可以是 Action、Flexibility_Thinking、Reflection、Structure 和 Value 可以是 1-7。 level_order 只改变Features的原始顺序。

这是我目前的代码,请帮忙!

TS_bar <-
  ggplot(FC_TS, aes(x = factor(Feature, level = level_order), y = Value, colour = Value >= 5)) +
   scale_colour_manual(name = 'High Structure', values = setNames(c('red', NA),c(T, F))) + geom_col(aes(fill = `Last Name`), position = "dodge") + coord_cartesian(ylim = c(1, 7)) + scale_y_continuous(n.breaks = 7) + theme_bw() 

【问题讨论】:

标签: r highlight geom-col


【解决方案1】:

试试:

ggplot(FC_TS, aes(x = factor(Feature, level = level_order), y = Value, colour = (Value >= 5 & Feature == “Structure”)))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-13
    • 2015-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-28
    相关资源
    最近更新 更多