[英]Image above a shape in plotly
我希望我的繪圖圖的元素按以下順序顯示:grid < shape < image.
如果我將 layer='below' 添加到我的形狀中,它會位於網格下方。
最小可重現示例:
library(plotly)
plot_ly(type = 'scatter', mode='markers') %>%
layout(shapes = list(type = 'line', x0 = 0, x1 = 1, y0 = 0, y1 = 1),
images = list(source = 'https://images.plot.ly/language-icons/api-home/r-logo.png?raw=true"',
x = 0.5, y = 0.5,
sizex=0.5, sizey=0.5,
xanchor = 'center', yanchor = "middle",
layer = 'above'))
我能想到的唯一方法是使用htmlwidgets
。
plot_ly(type = 'scatter', mode='markers') %>%
layout(shapes = list(type = 'line', x0 = 0, x1 = 1, y0 = 0, y1 = 1),
images = list(source = 'https://images.plot.ly/language-icons/api-home/r-logo.png?raw=true',
x = 0.5, y = 0.5,
sizex=0.5, sizey=0.5,
xref = "x", yref = "y",
xanchor = 'center', yanchor = "middle")) %>%
htmlwidgets::onRender("function(el){
m = document.querySelector('g.layer-above');
m.appendChild(m.firstElementChild);
}")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.