只是一个猜测,latticeExtra
有一个有趣的segplot
(它是一个扩展的点图)
读取一些数据:
dat <- read.table(text ='freq1 freq2 gain
2.0 6.0 43.
6.0 18.0 40.
8.5 10.5 50.
8.5 9.3 52.',head=T)
dat$compo <- paste('compo',1:nrow(dat),sep='')
library(latticeExtra)
segplot(reorder(factor(compo), gain)~freq1+freq2,
data=dat,draw.bands=FALSE,centers=gain,
segments.fun = panel.arrows,ends = "both",
angle = 90, length = 1, scales=list(y=list(cex=1.5)),
unit = "mm",
main = ' Range frequencies' ,sub= 'electronic components',
## a serious theme here :)
par.settings = theEconomist.theme(with.bg = TRUE))
编辑添加一些图片
library(png)
ll <- list.files(path=path_picts,patt='compo[0-9].*',full.names=T)
imgs <- lapply(ll,readPNG)
#ll <- gsub('.*(compo[0-9]).png','\\1',ll)
#names(imgs) <- ll
dat$compo <- paste('compo',1:nrow(dat),sep='')
segplot(factor(compo)~freq1+freq2,
data=dat,draw.bands=FALSE,centers=gain,
segments.fun = panel.arrows,ends = "both",
angle = 90, length = 1, scales=list(y=list(cex=1.5)),
unit = "mm",
main = ' Range frequencies' ,sub= 'electronic components',
par.settings = ggplot2like(),axis = axis.grid,
panel = function(x,y,...){
panel.segplot(x,y,...)
browser()
lapply(seq_along(ll),function(img){
x1 <- x[img];y1 <- y[img];
grid.raster(image=imgs[[img]],x=(x1+y1)*0.5,y=img,width=y1-x1, height=0.5,interpolate=F,
default.units = 'native')})
})