R马尔可夫链包,是否可以设置节点的坐标和大小?
我正在研究R的一些生物学行为问题,我有一个转换矩阵,我想用某种方式绘制它 我正在使用R马尔可夫链包,是否可以设置节点的坐标和大小?,r,plot,chain,markov,R,Plot,Chain,Markov,我正在研究R的一些生物学行为问题,我有一个转换矩阵,我想用某种方式绘制它 我正在使用markovchain包,这使得可视化变得容易 这是一个测试代码及其输出 > a<-array(0.25,dim = c(4,4)) > markov<-new("markovchain",transitionMatrix=a,states=c("a","b","c","d"), name="test") > markov test A 4 - dimensional disc
markovchain
包,这使得可视化变得容易
这是一个测试代码及其输出
> a<-array(0.25,dim = c(4,4))
> markov<-new("markovchain",transitionMatrix=a,states=c("a","b","c","d"), name="test")
> markov
test
A 4 - dimensional discrete Markov Chain defined by the following states:
a, b, c, d
The transition matrix (by rows) is defined as follows:
a b c d
a 0.25 0.25 0.25 0.25
b 0.25 0.25 0.25 0.25
c 0.25 0.25 0.25 0.25
d 0.25 0.25 0.25 0.25
> plot(markov)
马尔可夫
试验
由以下状态定义的四维离散马尔可夫链:
a、 b、c、d
转换矩阵(按行)定义如下:
a、b、c、d
a 0.25 0.25 0.25 0.25
b 0.25 0.25 0.25 0.25
c 0.25 0.25 0.25 0.25
d 0.25 0.25 0.25 0.25
>图(马尔可夫)
问题是,我想设置图形节点的坐标,将它们放置在2D网格或类似的东西中,并设置节点的大小。
我知道这个软件包可以与S4
一起使用,但我对它不是很熟悉,也不知道是否有任何参数对我有用。
有什么帮助吗?您可以这样做:
layout <- matrix(c(0,0,0,1,1,1,1,0), ncol = 2, byrow = TRUE)
# [,1] [,2]
# [1,] 0 0
# [2,] 0 1
# [3,] 1 1
# [4,] 1 0
plot(markov, vertex.size = 25, layout = layout)
你可以这样做:
layout <- matrix(c(4,-2,7,2,8,8,8,-4), ncol = 2, byrow = TRUE)
# [,1] [,2]
# [1,] 4 -2
# [2,] 7 2
# [3,] 8 8
# [4,] 8 -4
plot(markov, vertex.size = 25, layout = layout)