简体   繁体   English

如何在rbokeh中指定字形图层的顺序?

[英]How to specify order of glyph layers in rbokeh?

I am trying to build a network visualisation using the rbokeh package. 我正在尝试使用rbokeh包构建网络可视化。

library(igraph)
library(rbokeh)
library(dplyr)

 g <- random.graph.game(n=100,p=0.3)

 L <- as.data.frame(igraph::layout_with_fr(g)) %>% rename(x=V1,y=V2)

 url1 <- 'http://icons.veryicon.com/png/Business/Flat%20Finance/person.png'

 p <- figure(xlab = "x", ylab = "y", height = 500,width=1000,xgrid=F,ygrid=F,webgl = T,
             xaxes = F,yaxes = F,h_symmetry = T,v_symmetry = T) %>%
   ly_lines(x = L$x,y=L$y,color = '#FFA700', width = 4, alpha = 0.2) %>%
   ly_image_url(x = L$x, y=L$y, image_url = url1, w = rep(0.1,vcount(g)), h=rep(0.2,vcount(g)),
                anchor = "center",lname = 'nodes')

The resulting visualisation looks as intended except for the fact that the lines are drawn on top of the image glyphs. 所产生的可视化效果与预期的一样,只是在图像字形的顶部绘制了线条。 Is there a way to control the visual order of the layers in a way that the nodes (images) are drawn on top with lines drawn behind? 有没有一种方法可以控制图层的视觉顺序,即在顶部绘制节点(图像),在后面绘制线条?

在此处输入图片说明

The issue here is using webgl = TRUE . 这里的问题是使用webgl = TRUE For more details, see the Bokeh documentation (see both the "support" and "notes" sections. The main points there are that not all glyphs can be rendered with WebGL (yes for lines, no for images) and that "Glyphs drawn using WebGL are drawn on top of glyphs that are not drawn in WebGL." 有关更多详细信息,请参见Bokeh文档 (请参阅“支持”和“注释”部分。要点在于,并非所有字形都可以使用WebGL渲染(是的,对于线条,对于图像,不是),以及“使用WebGL被绘制在WebGL中未绘制的字形之上。”

If you get rid of webgl = TRUE , you should be in good shape! 如果您摆脱了webgl = TRUE ,那么您应该处于良好状态!

Also, to further answer the overall question of how to control the order of layers, the answer is that outside of edge cases like this where one layer was rendered with WebGL and the other wasn't, layers are drawn in the order that they are specified. 同样,为了进一步回答有关如何控制图层顺序的总体问题,答案是,在像这样的边缘情况之外,其中一层是使用WebGL渲染的,而另一层不是,则以它们的顺序绘制指定。

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

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