2017-07-26 57 views
0

我正在嘗試使用rbokeh軟件包構建網絡可視化。如何在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') 

由此產生的可視化看起來像預期的,除了在圖像字形頂部繪製線條這一事實。有沒有一種方法來控制圖層的視覺順序,使節點(圖像)在後面繪製線條的頂部繪製?

enter image description here

回答

1

這裏的問題是使用webgl = TRUE。有關更多詳細信息,請參見Bokeh documentation(請參閱「支持」和「筆記」部分。要點在於並非所有字形都可以使用WebGL呈現(對於線條而言,不適用於圖像)並且「使用WebGL繪製的字形上繪製未在WebGL的繪製字形的頂部「。

如果你擺脫webgl = TRUE,你應該在良好的狀態!

此外,進一步回答瞭如何控制順序的整體問題的層面,答案是,在這樣的邊緣情況之外,其中一層使用WebGL渲染,另一層不是,按照它們指定的順序繪製層。