data(mvad)
## Defining a state sequence object
mvad.seq <- seqdef(mvad[, 17:86])
## Growing a seqtree using Hamming distances:
seqt <- seqtree(mvad.seq~ male + Grammar + funemp + gcse5eq + fmpr + livboth,
data=mvad, R=1000, pval=0.05, seqdist.arg=list(method="HAM"))
## Generating the plot as a 300 dpi image in mytree.jpg
seqtreedisplay(seqt, filename = "mytree.jpg", type="d", border=NA, image.format = "jpg",
device.args=list(width=480*300/72, height=480*300/72, res=300))
Below is my previous answer that does not work because seqtreedisplay internally first generates texts and plots in bitmap format before saving them in the image.format.
## Drawing the tree as a pdf file and converting into jpeg
seqtreedisplay(seqt, filename = "mytree.pdf", type="d", border=NA, image.format = "pdf")
path <- getwd() ## retrieve the path
convert.g(path = path, fileroot = "mytree", from = "pdf", to = "jpeg",
options = "-units PixelsPerInch -density 300x300")
1 回答
您可以通过传递
device.args
参数(将被视为...
列表的元素)来控制seqtreedisplay
函数生成的输出文件的分辨率 .device.args
参数应该是将传递给已使用设备的参数列表(jpeg
时为image.format="jpg"
,否则为png
) .要获得300 dpi分辨率,您需要设置
res=300
,还要增加width
和height
.我用
mvad
数据说明:Below is my previous answer that does not work because seqtreedisplay internally first generates texts and plots in bitmap format before saving them in the image.format.
解决方案是为seqtreedisplay的结果选择矢量格式(例如pdf或eps),然后将该矢量文件转换为具有所需分辨率的光栅格式 .
假设您已经安装
ImageMagick
(ImageMagick
依赖于ImageMagick
转换为/从pdf或eps转换),您可以使用TraMineRextras
的convert.g
函数进行此转换 . 我在下面使用mvad
数据说明:生成的jpeg文件将位于当前文件夹的
jpeg
子目录中 .