首页 > 解决方案 > 更改 R 图中数据点的形状

问题描述

我按 PSName 对数据进行了分组,但希望通过更改每个组的形状来直观地区分这些组。我怎样才能做到这一点?这是我的情节代码:

 output$p <- renderPlotly({
    plot1 <- plot_ly(x = x(), y = y(), name = as.character(input$select), type = 'scatter', mode = 'markers', color = I("#696969"),
                     transforms = list(
                         list(
                             type = 'groupby',
                             groups = data$PSName,))) 
        add_lines(y = meaan(), name = paste("Mean =", meaan()[1]), color = I("black")) %>%
        add_lines(y = ucl(), name = paste("UCL =", ucl()[1]), color = I("green")) %>%
        add_lines(y = lcl(), name = paste("LCL =", lcl()[1]), color = I("green")) %>%
        add_lines(y = usl(), name = paste("USL =", usl()[1]), color = I("red")) %>%
        add_lines(y = lsl(), name = paste("LSL =", lsl()[1]), color = I("red")) %>%
        add_trace(x=rule5x(),y=rule5y(),mode='markers', color = I("blue"), name = paste("Rule 5 Violation =", length(rule5())))%>%
        add_trace(x=rule4x(),y=rule4y(),mode='markers', color = I("yellow"), name = paste("Rule 4 Violation =", length(rule4()))) %>%
        add_trace(x=rule1x(),y=rule1y(),mode='markers', color = I("red"), name = paste("Rule 1 Violation =", length(rule1()))) %>%
        layout(
            title = paste("Pov", input$select),
            yaxis = list(  showline = TRUE,
                           mirror = "ticks",
                           linecolor = toRGB("grey"),
                           linewidth = 1.85
            ),
            xaxis = list(  showline = TRUE,
                           mirror = "ticks",
                           linecolor = toRGB("grey"),
                           linewidth = 1.85,
                           tickangle=70))
})

标签: rr-plotly

解决方案


推荐阅读