0
我想在我使用igraph繪製的網絡圖下添加色彩漸變條。出於某種原因,顏色漸變條的軸標籤無法顯示。但是,當我在沒有網絡圖的情況下單獨繪製顏色漸變條時,軸標籤會完美顯示。任何建議?帶色彩梯度條的igraph網絡圖
colorstrip <- function(colors) {
count <- length(colors)
m <- matrix(1:count, count, 1)
par(mai=c(5, 50, 30, 50), cex.axis=2, ann=T, tck=-1)
image(m, col=colors, ylab="", axes=FALSE)
axis(side=3, at=seq(from=-0.165, to=1.22, by=0.332),
labels=letters[1:5])
}
library(igraph)
g <- graph.ring(10)
pdf("test_igraph.pdf", width=200, height=200)
layout(matrix(c(1,2), nrow=2), heights=c(2,0.5))
plot(g)
colorstrip(c("red", "mediumseagreen", "yellow", "blue"))
dev.off()
請在下次發佈的代碼中包含代碼,並確保代碼真正有效。如果你擺脫了不必要的細節,使代碼更小,它也會有所幫助。然後人們會更願意幫助你。 –