使雷达图的线在R中圆整地绘制

问题描述 投票:0回答:1

我有下面的雷达图的代码,这些代码是在R中的plotly包中创建的。直线从点到点是笔直的,但我想使其弯曲。我正在尝试阅读文档,以进行详细说明,但难以解释。

这是我的代码:

fig <- plot_ly(
    type = 'scatterpolar',
    r = c(1,3,2,4,1),
    theta = c("A","B","C","D","E"),
    fill = 'toself',
    line = list(c(shape = "spline"))
) 
fig %>%
    layout(
        polar = list(
            radialaxis = list(
                visible = T,
                range = c(0,4)
            )
        ),
        showlegend = F
    )

enter image description here

我希望这些点处的线弯曲。

r plotly data-visualization
1个回答
0
投票

没有必要将形状调用封装为矢量。

fig <- plot_ly(
  type = 'scatterpolar',
  mode = "markers",
  r = c(1,3,2,4,1, 1),
  theta = c("A","B","C","D","E", "A"),
  fill = 'toself',
  line = list(shape = 'spline')
) 
fig %>%
  layout(
    polar = list(
      radialaxis = list(
        visible = T,
        range = c(0,4)
      )
    ),
    showlegend = F
  )

enter image description here

P.S .:我已在输入向量的末尾添加了输入向量的第一个值,以连接末端。

© www.soinside.com 2019 - 2024. All rights reserved.