我是R的新手,他试图了解如何使用图表包和plotmat库,并希望为以下数据创建可读的可视化图像。现在有点难以阅读,我希望能够将self.shiftx和self.shifty分配给各个stateName / box,以便将它们移到更清晰的位置。
下面是文档,这表明我也许可以更改“一个值或维数等于A行数的向量”的位置。但是,我无法弄清楚如何将其映射到单独的stateNames,并且可以使用一些帮助。
让我知道您的想法。
https://www.rdocumentation.org/packages/diagram/versions/1.6.4/topics/plotmat
install.packages("markovchain")
install.packages("diagram")
install.packages("pracma")
library(expm)
library(markovchain)
library(diagram)
library(pracma)
stateNames <- c("Bears","Tigers","Trees","Pushmepullu","Hornets","Bees","Snakes")
Oz <- matrix(c(0.000994694960212202, 0.0295092838196286, 0.00431034482758621, 0.00729442970822281, 0.0019893899204244, 0.000994694960212202, 0.0019893899204244,0.000994694960212202, 0.0129310344827586, 0.0026525198938992, 0.000994694960212202, 0.000331564986737401, 0, 0.0013262599469496,0.0218832891246684, 0.160145888594164, 0.0344827586206897, 0.207559681697613, 0.0394562334217507, 0.00928381962864721, 0,0.0029840848806366, 0.10709549071618, 0.0626657824933687, 0.0029840848806366, 0.00762599469496021, 0.00364721485411141, 0.000994694960212202,0, 0.232427055702918, 0, 0, 0.0387931034482757, 0, 0,0, 0.000663129973474801, 0, 0.000994694960212202, 0, 0, 0,0, 0, 0, 0, 0, 0, 0
),
nrow=7, byrow=TRUE)
row.names(Oz) <- stateNames; colnames(Oz) <- stateNames
Oz
plotmat(Oz,pos = c(1,3,3),
lwd = 1, box.lwd = 2,
cex.txt = 0.8,
box.size = 0.1,
box.type = "circle",
box.prop = 0.5,
box.col = "light blue",
box.lcol = "dark blue",
arr.col = "red",
arr.length=.12,
arr.width=.2,
arr.lcol = "dark green",
self.cex = .75,
self.shifty = -.01,
self.shiftx = .13,
main = "Animals")
`