igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Determining exact coordinates for a drawn graph in Python


From: Tamas Nepusz
Subject: Re: [igraph] Determining exact coordinates for a drawn graph in Python
Date: Wed, 23 Jun 2010 19:34:09 +0100

Hello,

> I can draw the graph fine, but it seems like the coordinates that are 
> specified do not end up being exactly the coordinates used - they must be 
> scaled or stretched somehow, even when I use bbox=layout.bounding_box() in 
> igraph.plot(). I thought that this would use my exact coordinates, since I am 
> using the bounding box from my coordinates, but it seems like they are being 
> modified somehow, and I can't figure out how exactly they are changed.
The plotting function also takes into account the maximal vertex size; in 
particular, it takes the specified width and height, creates a box that spans 
from (0,0) to (width,height), then shrinks the box with half the maximum vertex 
size to leave a margin of max_vertex_size/2. This is to ensure that even those 
vertices are shown completely that end up at the edges of the layout. So, if 
you have a pre-calculated layout with the exact pixel coordinates, you can try 
this:

max_vertex_size = 10
bbox = layout.bounding_box()
width, height = bbox.width + max_vertex_size, bbox.height + max_vertex_size
plot(your_graph, (width, height))

By expanding the width and height of the plotting canvas with the maximum 
vertex size in advance, you are compensating for the contraction of the 
bounding box by half the vertex size in advance. Hope this helps.

-- 
Tamas


reply via email to

[Prev in Thread] Current Thread [Next in Thread]