首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R中的图表

R中的图表
EN

Stack Overflow用户
提问于 2013-01-02 03:56:45
回答 1查看 2K关注 0票数 14

我正在尝试开发图表。在R中开发这样的图表是可能的吗?

代码语言:javascript
复制
 myd <- data.frame (categories = c("Planes", "Ships", "Cars", "Trains"), 
values = c(15, 18, 22, 11))

组件图标位于以下位置:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-02 15:16:49

希望这会对你的众议院/议会有所帮助。

编辑:我忘了提及我的reference,我添加了一些解释。

代码语言:javascript
复制
library(lattice)
library(grid)


imgs.names <- c('WNinq','7dqJM','9E3Wj','tStmx')
library(png)
images <- lapply(imgs.names, function(x) 
     readPNG(paste(mypath,x,'.png',sep=''),native=TRUE))
## I generate some data because we don't give a reproducible example
x <- c(rep(0,4),rep(10,9),rep(20,3),rep(5,8),rep(4,8),rep(15,4),rep(13,8))
barchart(1:4~x, origin=0, col="yellow",xlim=c(0,30),
             xlab ='values',ylab='categories',title = 'Pictorial',
             scales = list(
               y = list(cex=2,col='blue', at = 1:4,labels = c('Trains','Cars','Ships','Planes')),
               x = list(cex=2,col='blue',at=seq(0,30,by=10))
               ),
             panel=function(x, y, ...) {
                panel.fill(col = rgb(1,1,205/255))    ## I had to pick up the same yellow color!!
                panel.grid()
                lapply(1:4,function(id){
                grid.raster(images[[id]], x=x[which(y==id)],  y=y[which(y==id)],
                           default.units="native",
                           just="left",
                           width =unit(2, "native"),
                           height=unit(0.7, "native"))
                }
            )
          }
         )
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14113691

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档