14

I am trying to develop pictorial charts. Is it possible to develop such charts in R ? enter image description here

 myd <- data.frame (categories = c("Planes", "Ships", "Cars", "Trains"), 
values = c(15, 18, 22, 11))

Component icons are here:

enter image description here enter image description here enter image description here enter image description here

fprd
  • 621
  • 7
  • 21
  • 3
    It's certainly *possible* but it will probably take considerable work. Take a look at http://stackoverflow.com/questions/2181902/how-to-use-an-image-as-a-point-in-ggplot and also look at `multsymbolbox` in the `plotrix` package – Ben Bolker Jan 01 '13 at 20:52
  • 5
    This sort of diagram flunks the Tufte test. Too much ink for too little info. Worse, it's difficult to tell whether one car, e.g., is worth more than one train. – Carl Witthoft Jan 02 '13 at 00:33
  • 1
    true may be good in science journal, but still may be useful in house / parliament floor, business meeting or general public meetings. – shNIL Jan 02 '13 at 01:20

1 Answers1

6

Hope that this would be helpful four your house / parliament floor

Edit: I forget to mention my reference and I add some explanations. enter image description here

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"))
                }
            )
          }
         )
agstudy
  • 119,832
  • 17
  • 199
  • 261