1. Create a new plotting device, and on top of that add the igraph plot. That gives you more control and allows you to, say, not restrict yourself to the square layout.
2. Use either white or some other color for the frame
3. Tryout netdiffuseR::igraph_vertex_rescale function. This function from the netdiffuseR R package, which I maintain as well, allows rescaling vertex size so that instead of using absolute values you can define how much of the plotting device, in percentage, will the largest and smallest node occupy.
library(igraph)
g <- structure(list(28, FALSE, c(6, 6, 8, 9, 10, 10, 11, 12, 13, 14,
15, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 19, 19, 19, 20, 20,
20, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24,
25, 25, 25, 25, 25, 25, 26, 26, 26, 27, 27, 27), c(1, 2, 2, 3,
2, 7, 6, 1, 4, 10, 2, 1, 12, 1, 3, 5, 6, 10, 13, 7, 15, 14, 17,
18, 0, 1, 2, 14, 18, 19, 0, 6, 7, 0, 9, 18, 17, 20, 22, 5, 7,
11, 0, 8, 10, 18, 22, 24, 6, 9, 14, 4, 21, 25), c(0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
53), c(24, 30, 33, 42, 0, 7, 11, 13, 25, 1, 2, 4, 10, 26, 3,
14, 8, 51, 15, 39, 6, 16, 31, 48, 5, 19, 32, 40, 43, 34, 49,
9, 17, 44, 41, 12, 18, 21, 27, 50, 20, 22, 36, 23, 28, 35, 45,
29, 37, 52, 38, 46, 47, 53), c(0, 0, 0, 0, 0, 0, 0, 2, 2, 3,
4, 6, 7, 8, 9, 10, 11, 13, 19, 21, 24, 30, 33, 36, 39, 42, 48,
51, 54), c(0, 4, 9, 14, 16, 18, 20, 24, 28, 29, 31, 34, 35, 36,
37, 40, 41, 41, 43, 47, 48, 49, 50, 52, 52, 53, 54, 54, 54),
list(c(1, 0, 1), structure(list(name = "Erdos renyi (gnp) graph",
type = "gnp", loops = FALSE, p = 0.142857142857143), .Names = c("name",
"type", "loops", "p")), structure(list(names = c("BE", "BG",
"CZ", "DK", "DE", "EE", "IE", "EL", "ES", "FR", "IT", "CY",
"LV", "LT", "LU", "HU", "MT", "NL", "AT", "PL", "PT", "RO",
"SI", "SK", "FI", "SE", "UK", "HR")), .Names = "names"),
structure(list(weight = c(16.3104184714332, 30.7293642773093,
1.51651715633125, 46.5498389394643, 117.400128622748,
9116.96298628885, 1101.62292417749, 12.3449820775232,
158.642126867059, 1.81516408646891, 760.982895191571,
1011.05564809154, 31677.1638228568, 189.344972592696,
13.1424122833109, 66.5517926330624, 12.0922729908787,
4.58139821481045, 90.1042955878783, 3.71064650396136,
90.4281997569113, 158.365362288124, 46.6972207187443,
30.3317841283049, 7.78960961626955, 1.95560245248322,
697.72330148994, 58.3866681241721, 660.780592399842,
1.30621866244087, 90.6566452600129, 411.372413931909,
50.4594917412583, 30.747955195432, 5.22931377396076,
26225.4597289607, 518.792688616195, 12998.9635603034,
69.4202716300456, 8.21344218621299, 0.582827301648975,
8.09867531337074, 107.652085596974, 1142.61073604216,
116.541846414264, 1.62280326041373, 405.914678311703,
0.386623934247936, 18.218603738158, 21.1501080346551,
0.158066706508139, 862.791072359265, 8.42653129127126,
20.0432021225717)), .Names = "weight"))), class = "igraph")
g <- upgrade_graph(g)
## l <- layout.fruchterman.reingold(g)
l <- layout_with_dh(g)
l <- layout.norm(l, -1,1, -1,1)
l <- norm_coords(layout.graphopt(g), xmin=-2, xmax=2, ymin=-2, ymax=2)
set.seed(1234)
# pdf("toy-network.pdf")
# I rather puttin the plot on a new plotting device
oldpar <- par(no.readonly = TRUE)
par(
mar = rep(2,4),
xpd = NA # This ensures you don't clip the images
)
plot.new()
plot.window(
xlim = range(l[,1]),
ylim = range(l[,2])
)
plot(g, layout=l,
## rescale=F, ylim=c(0.4,2.6), xlim=c(-3.4, -1.7),
## vertex.label.dist=0.5,
vertex.color=adjustcolor("blue", .5),
# White works nicer for the borders
# vertex.frame.color="#ff000033",
vertex.frame.color= "white",
edge.color="#55555533",
vertex.label=V(g)$names,
vertex.label.color="black",
# You can use netdiffuseR
# vertex.size=log(strength(g))*2,
vertex.size = netdiffuseR::igraph_vertex_rescale(
vertex.size = strength(g),
minmax.relative.size = c(.025, .1)
),
edge.width= log(1+E(g)$weight)
, edge.curved=0.3,
edge.label=NA,
# NEW OPTIONS
add = TRUE,
rescale=FALSE
)
par(oldpar)
# dev.off()