You need to enable JavaScript to run this app. ggplot2 geom_col与geom_point的fill、color使用及Shiny显示异常问题
优惠活动
大模型
产品
解决方案
定价
更多

ggplot2 geom_col与geom_point的fill、color使用及Shiny显示异常问题

关于geom_point的映射异常问题

我有一个关于geom_point使用的问题:

ui <- fluidPage(
  titlePanel("Test"),
  sidebarLayout(sidebarPanel(
    selectInput(
      "selectedColX",
      "Select colum for X axis",
      choices = c("tooling1","tooling2"),
      selected = "tooling1"
    ),
    
    selectInput(
      "selectedfill",
      "Energie X is vulling",
      choices = c("tooling1Energie","tooling2Energie"),
      selected = "tooling1Energie"
    ),
    
    selectInput(
      "selectedColY",
      "Select colum for Y axis",
      choices = c("subject1","subject2"),
      selected = "subject1"
    ), 
  
    selectInput(
      "selectedcolor",
      "Energie Y is omlijning",
      choices = c("subject1Energie","subject2Energie"),
      selected = "subject1Energie"
    )
  ),
  mainPanel(plotOutput("distPlot"))
)

server <- function(input, output) {
  output$distPlot <- renderPlot({
    x_axis <- input$selectedColX
    y_axis <- input$selectedColY
    fill <- input$selectedfill
    color <- input$selectedcolor
    
    gg <- ggplot(KEK, aes_string(x = x_axis, y = y_axis, fill = fill, col = color))
    gg <- gg + geom_col(size = 1.5) +
      facet_wrap(~anoniem)
    gg
  })
}

使用上述代码可获得直观的数据洞察,但geom_col图层无法添加形状(shape)映射,因此尝试将图层切换为geom_point,在新增shape参数且保持原有fill、col映射逻辑不变的情况下,fill维度的映射结果变为黑色(对应AccesEnergie),具体效果可参考附带的对比图。请问出现该现象的原因是什么,应如何解决?

geom_col 实现效果

geom_point 实现效果


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.11.03 02:45:01