[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] mycircle and arrows
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] mycircle and arrows |
Date: |
Thu, 29 Oct 2015 23:31:25 +0100 |
Hi,
When you add the vertex shape with `add.vertex.shape`, you have to
define two functions for the shape: the plotting function (which tells
igraph how to plot the shape) and the clipping function (which tells
igraph how to clip the edges to ensure that they are attached properly
to the boundary of the node). In the example that you showed, the
clipping function is igraph.shape.noclip, which, as its name implies,
does no clipping. Since your shape is essentially a circle, you can
re-use the clipping function of igraph's built-in circle shape
instead:
add.vertex.shape("fcircle", clip=vertex.shapes("circle")$clip,
plot=mycircle, ...)
T.
T.
On Thu, Oct 29, 2015 at 3:10 PM, Ted Toal <address@hidden> wrote:
> The example "mycircle" custom vertex with customizable thickness of borders,
> posted 15 Mar 2013, has a problem when edges are directed: the arrows are
> covered by the node circles. The arrow tip appears to end at the center of
> the circle. How might I fix this?
>
> Ted Toal
>
>
> library(igraph)
>
> mycircle <- function(coords, v=NULL, params) {
> vertex.color <- params("vertex", "color")
> if (length(vertex.color) != 1 && !is.null(v)) {
> vertex.color <- vertex.color[v]
> }
> vertex.size <- 1/200 * params("vertex", "size")
> if (length(vertex.size) != 1 && !is.null(v)) {
> vertex.size <- vertex.size[v]
> }
> vertex.frame.color <- params("vertex", "frame.color")
> if (length(vertex.frame.color) != 1 && !is.null(v)) {
> vertex.frame.color <- vertex.frame.color[v]
> }
> vertex.frame.width <- params("vertex", "frame.width")
> if (length(vertex.frame.width) != 1 && !is.null(v)) {
> vertex.frame.width <- vertex.frame.width[v]
> }
>
> mapply(coords[,1], coords[,2], vertex.color, vertex.frame.color,
> vertex.size, vertex.frame.width,
> FUN=function(x, y, bg, fg, size, lwd) {
> symbols(x=x, y=y, bg=bg, fg=fg, lwd=lwd,
> circles=size, add=TRUE, inches=FALSE)
> })
> }
>
> add.vertex.shape("fcircle", clip=igraph.shape.noclip,
> plot=mycircle, parameters=list(vertex.frame.color=1,
> vertex.frame.width=1))
>
> g=graph.formula(A-+B,B-+C)
> layout=matrix(c(2,1, 1,0, 3,0),byrow=TRUE,nrow=3)
> plot.igraph(g,layout=layout,edge.color="black",vertex.color="white",
> vertex.label=c("A","B","C"),vertex.size=20,vertex.label.cex=3,
> vertex.label.color="black",vertex.shape="fcircle",
>
> vertex.frame.color="black",edge.width=3,edge.arrow.size=1.2,edge.arrow.width=1.2)
>
>
>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>