2014-01-29 3 views
1

[도움말]R (igraph)의 정점으로 PNG 이미지

안녕하세요, R의 정점으로 png 이미지를 사용할 수있는 방법이 있습니까? 특히 igraph 패키지를 사용하면서? 좀 PNG 이미지 1.png 2.png 3.png이 예를 들어

나는 특정 1.png와 정점, 2.png와 다른 사람과 3.png과 나머지를 대체 할 수 ?

+0

, 내 대답을 참조하십시오. –

답변

2

이 새로운 raster 정점 모양 간단하다 : 실제로 훨씬 더 간단한 방법이있다

library(png) 
library(igraph) 

# To get an image to plot 
imgfilename <- file.path(tempdir(), "igraph2.png") 
imgfile <- download.file("http://igraph.sourceforge.net/images/igraph2.png", 
         destfile=imgfilename) 
img <- readPNG(imgfilename) 

g <- graph.ring(10) 
# This is a complex attribute, so supply a list here 
V(g)$raster <- replicate(vcount(g), img, simplify=FALSE) 
plot(g, vertex.shape="raster", vertex.label=NA, 
    vertex.size=1:10*5, vertex.size2=1:10*5) 

screenshot of plot