在 R 中绘制 igraph 对象时控制轴标签大小
Control axis label size when plotting igraph object in R
在 R 中绘制使用 igraph 生成的网络时,是否可以控制轴标签的字体大小?
与包 "network" 相反,cex.lab 在传递给 'plot' 时不会改变任何内容。
一个例子:
library(igraph)
testnet <- graph_from_adjacency_matrix(diag(10))
plot(testnet,xlab="This is xlab Text")
par(mfrow=c(2,3))
replicate(6,plot(testnet,xlab="This is xlab Text"))
replicate(6,plot(testnet,xlab="This is xlab Text",cex.lab=10))
一页多图,默认字体太小
请注意,我不是在谈论设置顶点标签的大小 (vertex.label.cex)。
这是解决您的问题的方法(即使它不是解决问题的方法)。获得所需内容的一种可能性是省略 x 标签并在绘图下方添加可自定义的文本。
par(mfrow=c(1,2))
# plot with x-axis label
plot(graph_from_adjacency_matrix(diag(10)), xlab = "mylab")
# plot w/o x-axis label + text
plot(graph_from_adjacency_matrix(diag(10)))
text(0, -1.8, labels = "myxlab", cex = 2.5)
这可能是您的结果。
另一种选择:将标签大小添加到par
。
所有地块均采用一种尺寸
rr <- 2; cc <- 3
par(mfrow=c(rr,cc), cex.lab=1.5)
replicate(6,plot(testnet,xlab="This is xlab Text"))
地块的不同大小:
par(mfrow = c(rr,cc))
plot.new()
cex.labs <- matrix(runif(2*3, 1, 3), ncol=cc, nrow=rr)
for (x in seq_len(rr))
for (y in seq_len(cc)) {
par(mfg=c(x,y), cex.lab = cex.labs[x,y])
plot(testnet,xlab="This is xlab Text")
}
在 R 中绘制使用 igraph 生成的网络时,是否可以控制轴标签的字体大小? 与包 "network" 相反,cex.lab 在传递给 'plot' 时不会改变任何内容。
一个例子:
library(igraph)
testnet <- graph_from_adjacency_matrix(diag(10))
plot(testnet,xlab="This is xlab Text")
par(mfrow=c(2,3))
replicate(6,plot(testnet,xlab="This is xlab Text"))
replicate(6,plot(testnet,xlab="This is xlab Text",cex.lab=10))
一页多图,默认字体太小
请注意,我不是在谈论设置顶点标签的大小 (vertex.label.cex)。
这是解决您的问题的方法(即使它不是解决问题的方法)。获得所需内容的一种可能性是省略 x 标签并在绘图下方添加可自定义的文本。
par(mfrow=c(1,2))
# plot with x-axis label
plot(graph_from_adjacency_matrix(diag(10)), xlab = "mylab")
# plot w/o x-axis label + text
plot(graph_from_adjacency_matrix(diag(10)))
text(0, -1.8, labels = "myxlab", cex = 2.5)
这可能是您的结果。
另一种选择:将标签大小添加到par
。
所有地块均采用一种尺寸
rr <- 2; cc <- 3
par(mfrow=c(rr,cc), cex.lab=1.5)
replicate(6,plot(testnet,xlab="This is xlab Text"))
地块的不同大小:
par(mfrow = c(rr,cc))
plot.new()
cex.labs <- matrix(runif(2*3, 1, 3), ncol=cc, nrow=rr)
for (x in seq_len(rr))
for (y in seq_len(cc)) {
par(mfg=c(x,y), cex.lab = cex.labs[x,y])
plot(testnet,xlab="This is xlab Text")
}