What I would like to do is to draw a barplot, then click on two colors in order to swap them. For what I read it seems Shiny would do the job. However, is there a way to identify the color at some given coordinates in an R plot without using Shiny? Something as follows:
# I start with this colour set
cols <- 0:9
plot(NA, xlim = c(1,10), ylim = c(1,10)); rect(1:9,1:9,2:10,2:10, col = cols)
# identify the two sets of coordinates to swap colour-wise
coords <- locator(2)
# get the colours with the non-existent colour_at() function
col1 <- colour_at(coords$x)
col2 <- colour_at(coords$y)
# swap colours in the colour set and finally plot again
col1.pos <- which(x == col1); col2.pos <- which(x == col2)
cols <- replace(x, c(col1pos, col2pos), x[c(col2pos, col1pos)])
plot(NA, xlim = c(1,10), ylim = c(1,10)); rect(1:9,1:9,2:10,2:10, col = cols)