【问题标题】:Changing aesthetics in R plotly radar chart改变 R plotly 雷达图中的美学
【发布时间】:2021-02-02 18:27:46
【问题描述】:

我想更改以下 plotly 雷达图的颜色,以及删除轴标签 中的 -0.2 此图由以下代码生成:

fig <- plot_ly(
      type = 'scatterpolar',
      fill = 'toself'
    )
fig <- fig %>%
      add_trace(
        r = as.numeric(threats.mod["Country avg.", ]),
        theta = threat.labs,
        name = 'Country Avg.'
      ) %>%
      add_trace(
        r = as.numeric(threats.mod["Selection", ]),
        theta = threat.labs,
        name = 'Selection'
      ) %>%
      layout(
        polar = list(
          radialaxis = list(
            visible = T,
            range = c(-0.2,1)
          )
        )
      )
    fig

【问题讨论】:

标签: r plotly


【解决方案1】:

这是我修复它的方法:

fig <- plot_ly(
      type = 'scatterpolar',
      fill = 'toself',
      marker = list(colorscale="Greys")
    )
    fig <- fig %>%
      add_trace(
        r = as.numeric(threats.mod["Country avg.", ]),
        theta = threat.labs,
        name = 'Country Avg.',
        fillcolor=rgb(153, 213, 148, 150, maxColorValue = 255),
        marker=list(color=rgb(153, 213, 148, maxColorValue = 255))
        ) %>%
      add_trace(
        r = as.numeric(threats.mod["Selection", ]),
        theta = threat.labs,
        name = 'Selection',
        fillcolor=rgb(252, 141,89, 150, maxColorValue = 255),
        marker=list(color=rgb(252, 141, 89, maxColorValue = 255))
      ) %>%
      layout(
        polar = list(
          radialaxis = list(
            visible = T,
            range = c(-20,100),
            tickmode = "array",
            tickvals = c(0, 50, 100),
            ticktext = c("0%", "50%", "100%"),
            angle= 0,
            tickangle = 0
          )
        )
      )

【讨论】:

    猜你喜欢
    • 2020-08-13
    • 2015-04-13
    • 2019-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-09
    • 2020-05-14
    相关资源
    最近更新 更多