简体   繁体   English

在 R plotly 雷达图中改变美学

[英]Changing aesthetics in R plotly radar chart

I would like to change reverse the colors of the following plotly radar chart, as well as removing the -0.2 in the axis labels我想改变以下绘图雷达图的颜色,并删除轴标签中的 -0.2 在此处输入图片说明 This plot was produced by the following code:该图由以下代码生成:

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

Here's how I fixed it:这是我修复它的方法:

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
          )
        )
      )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM