The short answer is, you need to set the asp
argument of the call to plot to 0
as the default is asp = 1
which produces the behavior you see (i.e., it's not a bug, it's a feature). The long answer with explanation follows.
As you noticed correctly, xaxis
varies according to yaxis
. Specifically, the x-axis has approxamitely the same distance between high and low numbers as yaxis
:
- If
yaxis = c(0,6)
, the x-axis goes from -3 to 4. 6 - 0 = 6
and 4 - (-3) = 7
- If
yaxis = c(0,3)
, the x-axis goes from -1 to 2. 3 - 0 = 2 - (-1) = 3
Igraph seems to keep a constant ratio between the axes.
If you call ?plot.igraph
(the plotting function called with an igraph
object, can also be found via help(package = "igraph")
), you find under See Also
:
igraph.plotting
for the detailed description of the plotting
parameters
And if you click on this link (or call ?igraph.plotting
)and go through the parameters you will find:
asp
A numeric constant, it gives the asp parameter for plot, the aspect ratio. Supply 0 here if you don't want to give an aspect ratio.
It is ignored by tkplot and rglplot.
Defaults to 1.
Hence the aspect parameter asp
defaults to 1
in igraph. If you want another ratio, set it to 0
:
plot(g,layout=l,rescale=F,axes=TRUE,ylim=c(0,6),xlim=c(0,1), asp = 0)
This answers your question. However, note that the points are now rather big. You will probably want to play around with the following parameters (found on ?igraph.plotting
but note that many of the parameters need to be prefixed by vertex.
as done by me):
vertex.size
Default is 15, 5 seems better
vertex.label.cex
Default is 1, 0.8 seems better.
The following produces a nicer plot:
plot(g,layout=l,rescale=F,axes=TRUE,ylim=c(0,6),xlim=c(0,1), asp = 0, vertex.size = 5, vertex.label.cex = 0.8)