我找到了一个很棒的grImport包,可以在.ps文件中阅读(向量和光栅)。它工作得很好,读者可以在这里找到包信息:
http://cran.r-project.org/web/packages/grImport/grImport.pdf
这里还有一个演示:
https://www.stat.auckland.ac.nz/~paul/R/grImport/import.pdf
我希望能够更改类Picture对象中的插槽的颜色,但不知道如何更改。因此,使用以下代码:
library(grImport); library(grid)
## Create a generic .ps file to read in
postscript("foo.ps")
plot.new()
text(.5, 0.5, "A", cex = 45)
dev.off()
## read in the .ps object
PostScriptTrace("foo.ps")
foo <- readPicture("foo.ps.xml")
grid.picture(foo)我如何改变对象foo,使A图形为浅灰,说#D0D0D0?
我试过:
class(foo)
foo
foo@rgb我假设这是一个S4对象,这可能是我努力工作的原因(我对s4缺乏了解)。
发布于 2014-04-11 09:03:55
使用str探索S4对象的结构:
R> str(foo)
Formal class 'Picture' [package "grImport"] with 2 slots
..@ paths :List of 1
.. ..$ text:Formal class 'PictureText' [package "grImport"] with 14 slots
.. .. .. ..@ string : Named chr "A"
.. .. .. .. ..- attr(*, "names")= chr "string"
.. .. .. ..@ w : num 3602
.. .. .. ..@ h : num 5400
.. .. .. ..@ bbox : num [1:4] 904 2644 4840 6154
.. .. .. ..@ angle : num 90
.. .. .. ..@ letters :List of 1
...可以通过以下方式更改颜色:
foo@paths$text@letters$path@rgb <- "#D0D0D0"https://stackoverflow.com/questions/23002825
复制相似问题