有什么方法可以在R中创建自定义点吗?我对pch
参数很熟悉,这里有很多选择,但是如果我需要绘制例如树的轮廓该怎么办?例如,如果我画点作为eps。(或类似)文件,我可以在R中使用它吗?。对于复杂的对象(fe树),按栅格进行求解不是很好。
您可以使用该grImport
程序包执行此操作。我在Inkscape中绘制了一个螺旋并将其保存为drawing.ps
。按照grImport小插图中概述的步骤,我们跟踪文件并将其读取为一种多边形。
setwd('~/R/')
library(grImport)
library(lattice)
PostScriptTrace("drawing.ps") # creates .xml in the working directory
spiral <- readPicture("drawing.ps.xml")
小插图使用点阵来绘制符号。您也可以使用基础图形,尽管需要从设备转换为绘图坐标。
# generate random data
x = runif(n = 10, min = 1, max = 10)
y = runif(n = 10, min = 1, max = 10)
# lattice (as in the vignette)
x11()
xyplot(y~x,
xlab = "x", ylab = "y",
panel = function(x, y) {
grid.symbols(spiral, x, y, units = "native", size = unit(10, "mm"))
})
# base graphics
x11()
plot(x, y, pty = 's', type = 'n', xlim = c(0, 10), ylim = c(0, 10))
xx = grconvertX(x = x, from = 'user', to = 'ndc')
yy = grconvertY(y = y, from = 'user', to = 'ndc')
grid.symbols(spiral, x = xx, y = yy, size = 0.05)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句