0

I made a waffle graph, showing that 5 out of 9 people are have training, but is it possible to somehow change the square icon to a stickman?

This is my code:


course <- read.csv("courses.csv")
courseES <- filter(course, GEO == "Ireland")



notparti <- c(round(100-courseES$Value,0))

work <- tibble(round(courseES$Value,0),notparti)

colnames(work) <- c('participating','not')


abc <- waffle(work/10, rows=2, size=0.9,  
       colors=c("#009999", "#808080"),
       title="Employed persons participating in job-related non-formal education")

abc + theme(legend.key.size = unit(10, "mm"))

And here is the result: enter image description here

And for the squares I would like to change it into stickman like this: enter image description here

Data: https://appsso.eurostat.ec.europa.eu/nui/show.do?dataset=qoe_ewcs_6_1&lang=en choosen 2015 Ireland value

Is it possible to somehow make something like this? Thanks in advance

markus
  • 25,843
  • 5
  • 39
  • 58
Hena
  • 71
  • 5
  • 1
    The version of `waffle` on github (*not* the one on CRAN) does this, and explains how in the vignettes – camille May 20 '21 at 22:03

1 Answers1

2

If you really have such a small picture, you could just create this by plotting the image. The image that you supplied had a lot of white space around it. I cropped that off first.

## Stack Overflow
## https://stackoverflow.com/q/67628271/4752675

library(png)

StickMan = readPNG("temp/wcBTO.png")

## create a green version of the stickman
GreenMan = StickMan
GreenMan[,,2] = 1


## Make a blank plot
plot(NULL ,xaxt='n',yaxt='n',bty='n',ylab='',xlab='', xlim=c(0,5), ylim=c(0,2))

## Add 5 green men
rasterImage(GreenMan,0,0,1,1)
rasterImage(GreenMan,0,1,1,2)
rasterImage(GreenMan,1,0,2,1)
rasterImage(GreenMan,1,1,2,2)
rasterImage(GreenMan,2,0,3,1)

## Add 4 black men
rasterImage(StickMan,3,0,4,1)
rasterImage(StickMan,3,1,4,2)
rasterImage(StickMan,4,0,5,1)
rasterImage(StickMan,4,1,5,2)

StickMan Plot

G5W
  • 36,531
  • 10
  • 47
  • 80