我正在尝试制作一个水平圆环图,其中一条线表示我的价值。 这样的事情:
下面是代码:
a <- list(
showticklabels = F,
autotick = F,
showgrid = F,
zeroline = F)
b <- list(
xref = 'paper',
yref = 'paper',
x = 0.5,
y = 0.5,
showarrow = FALSE,
text = '')
base_plot <- plot_ly(
type = "pie",
values = c(50, 7.14, 7.14, 7.14, 7.14, 7.14, 7.14, 7.14),
labels = c("-", "0", "20", "40", "60", "80", "100", "150"),
rotation = 90,
direction = "clockwise",
hole = 0.4,
textinfo = "none",
textposition = "outside",
hoverinfo = "none",
domain = list(x = c(0, 1), y = c(0, 1)),
marker = list(colors = c('#FFFFFF', '#440832', '#80180e', '#a52223', '#c0291b', '#f5c142', '#6aca3c', '#3980de')),
showlegend = F
) %>%
layout(
shapes = list(
list(
type = 'lines',
x0 = 0.5,
x1 = 0.5,
y0 = 0.5,
y1 = 1,
xref = 'paper',
yref = 'paper',
fillcolor = '#000000',
layer = "above"
)
),
xaxis = a,
yaxis = a,
annotations = b
)
查看Plotly文档,参数[layer =“above”]应解决我的问题,但它不起作用。如何使线条出现在图表上方?
答案 0 :(得分:0)
正如马克·桑德里所说的那样
您的代码在我的R 3.5.0中正常运行。与plotly_4.7.1.9000。正如预期的那样,我在图表上方得到了一条线。尝试安装plotly的开发版本:devtools :: install_github(&#34; ropensci / plotly&#34;)。