我希望使用gganimate和tweener将一些字母转换为其他字母。因此,我需要一个单词中每个字母的x,y坐标的数据帧作为ggplot的输入。
我真的不确定如何做到这一点,但我认为库(grImport)可能会有所帮助。
我通过打印创建了一个包含单词"hello“的Postscript文件,然后将输出保存到Postscript。我是here。
此代码读取hello.ps
library(grImport)
PostScriptTrace("figures/hello.ps", "hello.xml")
hello <- readPicture("hello.xml")
grid.picture(hello)hello是一个S4类对象。
我认为hello的结构包含单词"hello“的每个字母的x,y坐标,这是正确的吗?
如果是这样,我如何提取这些坐标?
发布于 2019-02-14 09:42:20
对于记录,解决方案是:
# Extract x, y coordinates of path from S4 object of class Picture
# letters[i], i is the index into the word, "hello".
x <- hello@paths$text@letters[2]$path@x
y <- hello@paths$text@letters[2]$path@yhttps://stackoverflow.com/questions/54662137
复制相似问题