1

更改每组的颜色后,我在雷达图的图例中遇到了一个新问题。

图例显示了每个组的名称(这是正确的),但它也显示了颜色名称(rgb 代码)。

它看起来像这样:

测试

是否可以只显示组名?

我将留下一个可重现的例子:

attrib1 <- c( 2, 3, 5)
attrib2 <- c( 1, 2, 5)
attrib3 <- c( 5, 2, 4)
attrib4 <- c( 4, 3, 1)
attrib5 <- c( 2, 2, 1)


teams_final <- data.frame(attrib1, attrib2, attrib3, attrib4, attrib5, attrib1)

row.names(teams_final) <- c("A Team", "B Team", "C Team")

labels <- c("attrib1", "attrib2", "attrib3", "attrib4", "attrib5", "attrib1")


library(plotly)

p <- plot_ly(
    type = 'scatterpolar', fill = 'toself') %>%

    add_trace(r = unname(teams_final[1, ]), theta = labels, name = "A Team", 
              fillcolor = 'rgba(64, 64, 64, 0.5)', marker = list(color = '#404040'),
              hoverinfo = "text", 
              text = ~paste(labels, '<br> Importance: ', unname(teams_final[1, ]))) %>%

    add_trace(r = unname(teams_final[2, ]), theta = labels, name = "B Team",
              fillcolor = 'rgba(171, 35, 35, 0.5)', marker = list(color = '#AB2323'), 
              hoverinfo = "text", 
              text = ~paste(labels, '<br> Importance: ', unname(teams_final[1, ]))) %>%

    add_trace(r = unname(teams_final[3, ]), theta = labels, name = "C Team",
              fillcolor = 'rgba(241, 103, 69, 0.5)', marker = list(color = '#F16745'), 
              hoverinfo = "text", 
              text = ~paste(labels, '<br> Importance: ', unname(teams_final[1, ]))) %>%

    layout(polar = list(radialaxis = list(visible = T, range = c(0,6))), 
         font = list(size = 11, color = "#202020"))

p

干杯,

布鲁诺

4

0 回答 0