1

I'm looking for a way to plot my data. Suppose you have a number of algorithms that produce a ranked list, and a classifier that identifies each item in the list as true or false. How can I produce a chart that puts each algorithm beside each other and each rank has its own square stacked as follow:

      __   __
 3   |TP| |FP|
     |__| |__|
 2   |FP| |TP|
     |__| |__|
 1   |TP| |TP|
     |__| |__|
      a    b

Where TP could be coloured green and FP could be coloured red for example.

Robert
  • 8,406
  • 9
  • 38
  • 57

2 Answers2

1

You may use ggplot2 for drawing a stacked barplot. However a better way to compare the true/false positive/negatives of algorithms is precision/recall (same as selectivity/specificity) chart.

Community
  • 1
  • 1
Ali
  • 9,440
  • 12
  • 62
  • 92
1

It can be done very easily with base R, using the heatmap() function.

Try this:

# Dataframe with TRUE/FALSE items
mydf <- data.frame(a = c(T, F, T), b = c(T, T,F))

# Transform booleans into 1s and 0s, and plot heatmap
heatmap(apply(mydf, 2, as.integer),
        col = c("red", "lightgreen"),
        xlab = "Algorithm", 
        ylab = "Item", 
        main = "False positives in red", 
        Rowv = NA, 
        Colv = NA,
        scale = "column")

True/False heatmap plot generated with R

HAVB
  • 1,858
  • 1
  • 22
  • 37