igraph 部分填充的顶点

3

给定一个分数向量(在[0:1]区间上),我想要绘制部分填充的顶点。 也就是说,如果分数为1/2,则相应的顶点应该是半填充的(半球)。 如果分数是1/4,则相应的顶点仅在一个季度内(四分之一球体)。 依此类推...

library('igraph')
N <- 10
g <- graph.full(N)
values <- runif(N,0,1) # vector of fractions
V(g)$shape <-'circle'

plot.igraph(g,...)

例如:http://www.google.ch/imgres?q=three+quarter-filled+circle&um=1&hl=de&sa=N&biw=1024&bih=751&tbm=isch&tbnid=fCz7FZ6JG38DzM:&imgrefurl=http://www.clipartstation.com/clipart_indexer4/index/search%3Fkeywords%3DART&docid=UPphGFugM1pYGM&imgurl=http://www.clipartstation.com/clipart/resized/Math/Transformations/__100x100//three%252520quarters%252520blue%252520circle.gif&w=100&h=99&ei=ETsNUNDeHbCL4gTT5rjACg&zoom=1&iact=rc&dur=331&sig=101088608959992434501&page=1&tbnh=79&tbnw=80&start=0&ndsp=24&ved=1t:429,r:8,s:0,i:97&tx=49&ty=38

请提供需要翻译的英文文本。 - Axel Axel
1个回答

3
如果你使用版本为0.6的 igraph 软件包,你应该能够在 plot() 中使用 pie 顶点。这种情况下你的代码应该是:
library(igraph)
N <- 10
g <- graph.full(N)

values <- runif(N,0,1) # vector of fractions
plot(g, vertex.shape="pie", vertex.pie=values, vertex.frame.color="white", 
     vertex.pie.color=list(heat.colors(5)))

如果你还没有做到这一点(就像我一样),你可以在这里找到代码,运行后可以使用pie作为顶点。

1
values 应该是一个向量列表,例如 values <- lapply( runif(N,0,1), function(u) c(u,1-u) ) 吗? - Vincent Zoonekynd
@DiscreteCircle:你的解决方案在我的igraph版本上也不起作用。但是你提供的Gabor Csardi帖子的超链接很好 - 完美地解决了问题!谢谢 - Axel Axel
@Vincent Zoonekynd:你说得对。如果馅饼只有一种颜色,那就不够好看了。 - Axel Axel

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接