有没有办法在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")
Run Code Online (Sandbox Code Playgroud)
小插图使用晶格绘制符号.您也可以使用基本图形,但需要从设备到绘图坐标进行转换.
# 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)
Run Code Online (Sandbox Code Playgroud)
